Problem with datagrid

  • Thread starter Thread starter mario
  • Start date Start date
M

mario

I using datagrid and windows form in C#

Question 1:
I have selected a specified row and if I resize the form with the datagrid
in it , I cannopt see anymore the row i have seleted until i scroll to it.
I want to do this...
the selected row must be all the time stay visible.
How can I do That ????

Question 2:
If I selected a row and i sort the grid, i loose the selected row .It's
appears the grid keep the Current index and not
the row i had selected.
How do I keep the row I have selected and not the current Index ????
thx
 
Hello Mario,
Question 2:
If I selected a row and i sort the grid, i loose the selected row .It's
appears the grid keep the Current index and not
the row i had selected.
How do I keep the row I have selected and not the current Index ????

I see two approaches to this.

The first one is to remember the row's unique key when the grid is
re-sorted, then look up the remembered key and determine the new row number
for this row (of course the look up should be performed in the dataview
obtained through CurrencyManager.List property and not in the bound data
table).

The second approach is to subscribe to the DataView's ListChanged event and
react on ItemMoved events (but I am not sure they are raised when sort order
changes - they are raised for sure when a row changes its place in the view
after a value has been changed in a column the view is sorted by.)
 
Back
Top