110,539
社区成员
发帖
与我相关
我的任务
分享
class ListViewItemComparer : IComparer
{
private int nCol;
private bool bAscend;
public ListViewItemComparer()
{
nCol = 0;
}
public ListViewItemComparer(int nColumn, bool bAscend)
{
this.nCol = nColumn;
this.bAscend = bAscend;
}
public int Compare(object x, object y)
{
int nCompare = String.Compare(((ListViewItem)x).SubItems[nCol].Text, ((ListViewItem)y).SubItems[nCol].Text);
return this.bAscend ? nCompare : - nCompare;
}
}
private void ListView1_ColumnClick(object sender, System.Windows.Forms.ColumnClickEventArgs e)
{
bLvImage = !bLvImage;
this.ListView1.ListViewItemSorter = new ListViewItemComparer(e.Column, bLvImage);
}
dataGridView1.ReadOnly = true;
dataGridView1.RowHeadersVisible = false;
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;