我有我在 DataGridView 上填写的数据库。
我尝试按这样的 Heder 对我的 DataGridView 进行排序:
private void dataGridView1_ColumnHeaderMouseClick(object sender,DataGridViewCellMouseEventArgs e)
{
SortOrder ss = dataGridView1.Columns[e.ColumnIndex].HeaderCell.SortGlyphDirection;
string strColumnName = dataGridView1.Columns[e.ColumnIndex].Name;
label8.Text = "Column: " + strColumnName + " - " + "sort order: " + ss.ToString();
if (strColumnName == "Column9")
{
if (ss == SortOrder.Ascending)
{
A_table = "Tmp_Kabat_SfiraTbl";
SQL = "SELECT Color,Line,Makat,Des,sQty,sNewQty,CountBy_Name,UserName,TermNum,NewQty,Qty from " + A_table + " order by NewQty asc";
}
else if (ss == SortOrder.Descending)
{
A_table = "Tmp_Kabat_SfiraTbl";
SQL = "SELECT Color,Line,Makat,Des,sQty,sNewQty,CountBy_Name,UserName,TermNum,NewQty,Qty from " + A_table + " order by NewQty desc";
}
dsView = new DataSet();
adp = new OleDbDataAdapter(SQL, Main.Conn);
adp.Fill(dsView, A_table);
adp.Dispose();
dataGridView1.DataSource = dsView.Tables[A_table].DefaultView;
this.dataGridView1.ClearSelection();
}
}
它只工作一次,它不会从 asc 更改为 desc 排序
可能是什么问题?