Datagrid CurrentRowIndex returns -1?
It seems rather strange. I have a Datagrid (.net 3.5 cf) that I link to List or Inventory []. When I click on a row and then click on the button to perform an action when I bind to the list CurrentRowIndex is -1. When I bind to Inventory [] and perform the same action CurrentRowIndex is returned with the selected row, why is this?
grdBatch.DataSource = InventoryItems.ToArray();
against
grdBatch.DataSource = InventoryItems;
+1
a source to share
1 answer
Hmmm I'm having trouble replicating the issue (array and list works great for me). What is the target system? Also, what is the operation you are performing?
You can try using a BindingSource as an intermediary between your list and your datagrid, but not sure if that helps. Something like this:
BindingSource bs = new BindingSource();
bs.DataSource = InventoryItems;
grdBatch.DataSource = bs;
0
a source to share