2009-05-20 105 views
1

這似乎很奇怪。我有一個Datagrid(.net 3.5 cf),可以綁定到List或Inventory []。當我點擊一行,然後點擊一個按鈕來執行一個動作時,我綁定到一個List CurrentRowIndex是-1。當我綁定到Inventory []並執行相同的操作時,CurrentRowIndex返回所選行爲什麼?Datagrid CurrentRowIndex返回-1?

grdBatch.DataSource = InventoryItems.ToArray(); 

VS

grdBatch.DataSource = InventoryItems; 
+0

我遇到了與.NET CF 2.0 DataGrid類似的問題。這似乎與DataGrid被放置在TabPage中有關,但我仍未弄清楚爲什麼會發生這種情況。 – 2012-07-10 12:02:17

回答

0

嗯,我無法複製的問題(陣列和同時列出的工作對我罰款)。目標系統是什麼?另外,您正在執行的操作是什麼?

你可能會嘗試使用BindingSource作爲你的列表和你的數據網格之間的中介,但不知道它是否會有所幫助。沿着這些線:

BindingSource bs = new BindingSource(); 
bs.DataSource = InventoryItems; 
grdBatch.DataSource = bs;