private void view_ColumnClicked(object sender, GridViewEventArgs e) { var view = sender as GridView; var col = e.Column; if (col.Tag == null) { col.Tag = 0; } var tag = (int)col.Tag; col.Tag = tag = 1 - tag; if (col.Index == 0) { if (tag == 0) { view.Items.Sort((a, b) => a.Text.CompareTo(b.Text)); } else { view.Items.Sort((b, a) => a.Text.CompareTo(b.Text)); } } else { if (tag == 0) { view.Items.Sort((a, b) => a.SubItems[col.Index - 1].Text.CompareTo(b.SubItems[col.Index - 1].Text)); } else { view.Items.Sort((b, a) => a.SubItems[col.Index - 1].Text.CompareTo(b.SubItems[col.Index - 1].Text)); } } }
void view_ColumnClicked(object sender, GridViewEventArgs e) { GridView view = sender as GridView; GridColumn col = e.Column; if (col.Tag == null) col.Tag = 0; int tag = (int)col.Tag; col.Tag = tag = 1 - tag; if (col.Index == 0) { if (tag == 0) view.Items.Sort((a, b) => a.Text.CompareTo(b.Text)); else view.Items.Sort((b, a) => a.Text.CompareTo(b.Text)); } else { if (tag == 0) view.Items.Sort((a, b) => a.SubItems[col.Index - 1].Text.CompareTo(b.SubItems[col.Index - 1].Text)); else view.Items.Sort((b, a) => a.SubItems[col.Index - 1].Text.CompareTo(b.SubItems[col.Index - 1].Text)); } }