代码如下 | 复制代码 |
#region 自定义变量 intcurrentCol = -1; boolsort; #endregion//列头点击事件
privatevoidlvw_ColumnClick(objectsender, ColumnClickEventArgs e) { stringAsc = ((char)0x25bc).ToString().PadLeft(4,' '); stringDes = ((char)0x25b2).ToString().PadLeft(4,' ');
if(sort ==false) { sort =true; stringoldStr =this.lvw.Columns[e.Column].Text.TrimEnd((char)0x25bc, (char)0x25b2,' '); this.lvw.Columns[e.Column].Text = oldStr + Des; } elseif(sort ==true) { sort =false; stringoldStr =this.lvw.Columns[e.Column].Text.TrimEnd((char)0x25bc, (char)0x25b2,' '); this.lvw.Columns[e.Column].Text = oldStr + Asc; }
if(lvw.Columns[e.Column].Tag.ToString()=="n")//在设计器中把列头的tag设为"n",则表示该列按数字比较器处理,否则为文本 lvw.ListViewItemSorter =newListViewItemComparerNum(e.Column, sort); else lvw.ListViewItemSorter =newListViewItemComparer(e.Column, sort); this.lvw.Sort(); introwCount =this.lvw.Items.Count; if(currentCol != -1) { if(e.Column != currentCol) this.lvw.Columns[currentCol].Text =this.lvw.Columns[currentCol].Text.TrimEnd((char)0x25bc, (char)0x25b2,' '); } currentCol = e.Column; }//文本比较器public class ListViewItemComparer : IComparer { publicboolsort_b; publicSortOrder order = SortOrder.Ascending;
privateintcol;
publicListViewItemComparer() { col = 0; }
publicListViewItemComparer(intcolumn,boolsort) { col = column; sort_b = sort; }
publicintCompare(objectx,objecty) { if(sort_b) { returnString.Compare(((ListViewItem)x).SubItems[col].Text, ((ListViewItem)y).SubItems[col].Text); } else { returnString.Compare(((ListViewItem)y).SubItems[col].Text, ((ListViewItem)x).SubItems[col].Text); } } } //数字比较器 publicclassListViewItemComparerNum : IComparer { publicboolsort_b; publicSortOrder order = SortOrder.Ascending;
privateintcol;
publicListViewItemComparerNum() { col = 0; }
publicListViewItemComparerNum(intcolumn,boolsort) { col = column; sort_b = sort; }
publicintCompare(objectx,objecty) { decimald1=Convert.ToDecimal(((ListViewItem)x).SubItems[col].Text); decimald2=Convert.ToDecimal(((ListViewItem)y).SubItems[col].Text); if(sort_b) { returndecimal.Compare(d1,d2); } else { returndecimal.Compare(d2,d1); } } } |
梦想家园汉化版 最新版v1.3.0
梦想家园汉化安卓版是一款以泡泡玛特为主题,玩法独特的模拟经营
服从我 (Obey Me!)安卓版v8.1.11
服从我(obey me)是一款让你陷入ikemen恶魔们深情
佩皮超级商店 免费版v1.13.1
佩皮超级商店(Pepi Super Stores)是一款经营
船舶墓地模拟器内置菜单最新版本 v142
船舶墓地模拟器内置菜单版是一款模拟经营类游戏,玩家们将在这里
铠甲勇士捕将变身器模拟器 最新版v1.5
铠甲勇士捕将变身器模拟器是一款有着丰富选择的腰带召唤器,该召