2009-05-20 104 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;