-
-
-
//列头点击事件
-
private void lvw_ColumnClick(object sender, ColumnClickEventArgs e)
-
-
string Asc = ((char)0x25bc).ToString().PadLeft(4, ' ');
-
string Des = ((char)0x25b2).ToString().PadLeft(4, ' ');
-
-
-
-
-
string oldStr = this.lvw.Columns[e.Column].Text.TrimEnd((char)0x25bc, (char)0x25b2, ' ');
-
this.lvw.Columns[e.Column].Text = oldStr + Des;
-
-
-
-
-
string oldStr = 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")
-
lvw.ListViewItemSorter = new ListViewItemComparerNum(e.Column, sort);
-
-
lvw.ListViewItemSorter = new ListViewItemComparer(e.Column, sort);
-
-
int rowCount = this.lvw.Items.Count;
-
-
-
if (e.Column != currentCol)
-
this.lvw.Columns[currentCol].Text = this.lvw.Columns[currentCol].Text.TrimEnd((char)0x25bc, (char)0x25b2, ' ');
-
-
-
-
public class ListViewItemComparer : IComparer
-
-
-
public SortOrder order = SortOrder.Ascending;
-
-
-
-
public ListViewItemComparer()
-
-
-
-
-
public ListViewItemComparer(int column, bool sort)
-
-
-
-
-
-
public int Compare(object x, object y)
-
-
-
-
return String.Compare(((ListViewItem)x).SubItems[col].Text, ((ListViewItem)y).SubItems[col].Text);
-
-
-
-
return String.Compare(((ListViewItem)y).SubItems[col].Text, ((ListViewItem)x).SubItems[col].Text);
-
-
-
-
-
public class ListViewItemComparerNum : IComparer
-
-
-
public SortOrder order = SortOrder.Ascending;
-
-
-
-
public ListViewItemComparerNum()
-
-
-
-
-
public ListViewItemComparerNum(int column, bool sort)
-
-
-
-
-
-
public int Compare(object x, object y)
-
-
decimal d1=Convert.ToDecimal(((ListViewItem)x).SubItems[col].Text);
-
decimal d2=Convert.ToDecimal(((ListViewItem)y).SubItems[col].Text);
-
-
-
return decimal.Compare(d1,d2);
-
-
-
-
return decimal.Compare(d2,d1);
-
-
-