日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

几个以前项目中使用的函数 (转)

發(fā)布時間:2024/6/3 编程问答 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 几个以前项目中使用的函数 (转) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
//作用:把ListBox中的全部內(nèi)容轉(zhuǎn)換成一個字符串,各個字段間用,分隔
??//
??//參數(shù):Lists,需要轉(zhuǎn)換的ListBox.items
??//
??//返回值:轉(zhuǎn)換好的字符串
??//
??public string ListToString(ListItemCollection Lists)
??{
???string result="";
???for(int i=0;i<Lists.Count;i++)
???{
????if (i==0)
????{
?????result=Lists[i].Text;
????}
????else
????{
?????result=result+","+Lists[i].Text;
????}
???}
???return result;
??}


??//
??//作用:把string中的全部內(nèi)容轉(zhuǎn)換成ListItemCollection從而綁定到Listbox
??//
??//參數(shù):str,需要轉(zhuǎn)換的字符串
??//
??//返回值:轉(zhuǎn)換好的ListItemCollection
??//
??public ListItemCollection StringToList(string str)
??{
???ListItemCollection lists=new ListItemCollection();
???if(str=="")??????????????????????????????????????? //字符串為空
???{
????errPosition="ListItemCollection";
????errMsg="字符串為空";
???}
???else if(str.IndexOf(",")==0)??????????????????????? //首位為","
???{
????errPosition="ListItemCollection";
????errMsg="首位為,";
???}
???else if(str.Substring(str.Length-1,1)==",")??????? //尾位為","
???{
????errPosition="ListItemCollection";
????errMsg="尾位為,";
???}
???else
???{
????while (str.IndexOf(",")>0)
????{
?????int position=str.IndexOf(",") ;
?????lists.Add(str.Substring(0,position));
?????str=str.Remove(0,position+1);
????}
????lists.Add(str);
???}
???return lists;
??}

??//
??//作用:把源ListBox中的選中數(shù)據(jù)移動到目標(biāo)ListBox
??//
??//參數(shù):FromLists,源ListBox
??//
??public static void MoveListBoxSelectedItem
???(ListItemCollection FromLists,ListItemCollection ToLists)
??{
???for(int i=FromLists.Count-1;i>=0;i--)
???{
????if (FromLists[i].Selected)
????{
?????FromLists[i].Selected=false;
?????ToLists.Add(FromLists[i]);
?????FromLists.Remove(FromLists[i]);
????}
???}
??}

??//
??//作用:把源ListBox中的全部數(shù)據(jù)移動到目標(biāo)ListBox
??//
??//參數(shù):FromLists,源ListBox
??//
??public static void MoveListBoxAllItem
???(ListItemCollection FromLists,ListItemCollection ToLists)
??{
???for(int i=FromLists.Count-1;i>=0;i--)
???{
????FromLists[i].Selected=false;
????ToLists.Add(FromLists[i]);
????FromLists.Remove(FromLists[i]);
???}
??}

??//
??//作用:輸入年月返回月份的天數(shù)的集合
??//
??//參數(shù):YYYY年,MM月
??//
??//返回值:本月的天數(shù)的ArrayList
??//
??public static ArrayList GetDaysInMonth(int YYYY,int MM)
??{
???int day=DateTime.DaysInMonth(YYYY,MM);
???ArrayList days=new ArrayList();
???for (int i=1;i<=day;i++)
???{
????days.Add(i);
???}
???return days;
??}


??//
??//作用:輸入選中天數(shù)的集合,返回其中的最小和最大的天數(shù)
??//
??//參數(shù):dates,把Calendar.SelectedDates傳入即可
??//
??//返回值:兩個數(shù)值的ArrayList,第一個為最小天數(shù),第二個為最大天數(shù)
??//
??public static ArrayList GetMinMaxDate(SelectedDatesCollection dates)
??{
???ArrayList Result=new ArrayList();
???DateTime min=new DateTime();
???DateTime max=new DateTime();
???for(int i=0;i<dates.Count;i++)
???{
????if (i>0)
????{
?????if(dates[i]<min)
?????{
??????min=dates[i];
?????}
?????if(dates[i]>max)
?????{
??????max=dates[i];
?????}
????}
????else
????{
?????min=dates[i];
?????max=dates[i];
????}
???}
???Result.Add(min);
???Result.Add(max);
???return Result;
??}

調(diào)用函數(shù)是碰到ListItemCollection 使用ListBox.Items做參數(shù)

轉(zhuǎn)載于:https://www.cnblogs.com/jodyjin800730/archive/2006/02/17/332611.html

總結(jié)

以上是生活随笔為你收集整理的几个以前项目中使用的函数 (转)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。