0

Can I have first item not selected on Windows.Control.DataGrid on start? I have selected first item - first row and first column every time the data are being binded, could I change it? After binding data I have(cells are not really empty - data is not a problem): https://i.stack.imgur.com/rTWez.jpg I want to have not selected first cell (that with blue border)

2 Answers2

0

After you have instantiated the grid and populated it, you can then call

datagrid.ClearSelection();

That should do the trick!!!

BigBaz
  • 83
  • 4
0

Right, I may have gone down the wrong track again but try this.

It looks like binding anything to the DataGrid control WILL reset the selection (not 100% on that).

You could use the ItemDataBound event for the DataGrid. This will fire AFTER an item has been bound to the control and if necessary you could 'deselect' whatever cell is selected from this event.

Also if you wanted to preserve any selection made by the user then you could use the 'DataBinding' event to check whether the user has a cell selected ('Occurs when the server control binds to a data source.'); then you could save the index value and re-select it after the data bind.

More info - MSDN

Similar (but importantly not the same) question - DataGrid - grid selection is reset when new Data is arrived

Hope this helps

Community
  • 1
  • 1
Jammerz858
  • 1,605
  • 3
  • 14
  • 14