如何在infodatagridview中,將有運算式欄位來排序?
參考方法如:
先將該運算式欄位的SortMode設為Programmatic,在InfoDataGridView的CellClick事件中設計,假設運算式欄位為EMPTextBoxColumn:
private void infoDataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex == -1 && e.ColumnIndex == this.infoDataGridView1.Columns.IndexOf(EMPTextBoxColumn))
{
if (infoDataGridView1.SortedColumn == EMPTextBoxColumn && infoDataGridView1.SortOrder == SortOrder.Ascending)
{
this.ibsMaster.Sort = "EMP desc"; // ibsMaster為對應的InfoBindingSource
}
else
{
this.ibsMaster.Sort = "EMP asc";
}
}
}