2011-02-24 78 views

回答

0

我解決了問題,通過一個ID排序行。

6

DataGridView綁定到您的源集合,所以如果您將它們插入頂部,它們應顯示在頂部。嘗試添加新項目插入它們:

list.Insert(0, item) 
+0

你的答案顯然是最好的,我想這根本不清楚你的意思。 – 2011-06-11 07:22:20

0

不要打擾排序,那麼你必須處理Keys。根本就提到了什麼jjrdk並使用內置的插件(rowIndex位置,rowObject)方法的功能,像這樣:

'First create a new row 
Dim tmpRow = New DataGridViewRow 

'Dimension or do whatever 
tmpRow.Height = _cellRectSize 

'Add the row to your DataGridView(i.e dgvEditor) at index 0 for it to be at top 
Me.dgvEditor.Rows.Insert(0, tmpRow) 

在幾個項目中使用這個確切的代碼和它工作得很好。希望這可以幫助那裏的人!

1

這種方式爲我工作:

dataGridView1.Rows.Insert(0, new string[] { 
    "Data1", "Data2", "Data3" // [, "DataN"] .. 
}); 

希望它能幫助。