Move row up and down in datagrid

kaisersoze said:
How to move complete row up or down in datagrid or any grid is fine.

You need to manipulate the DataSource which your DataGrid is bound to.....if it is a DataTable, simply reposition the associated DataRow and it will be reflected in your DataGrid.
 
donnacha said:
How do you physically want to do this, with drag drop or what have you in mind.

1. The user selects one row
2. there will be up arrow and down arrow.
3. If the user wants to move up, the user clicks up arrow button
4. If the user wants to move down, then the user clicks down arrow button
5. if the row is at the top then up arrow button becomes disabled
6. if the row is at the bottom then down arrow button becomes disabled
 
kaisersoze:
I do the exact same thing you are describing in an application I developed through manipulation of the bound DataSource as I desribed above.
I take the index of the selected row in the grid and retrieve the corresponding DataRow in the DataTable and then move the DataRow up or down one position. If the user hits index 0 or Rows.Count - 1, I disable the corresponding button.
If the user selects row index 0 or Rows.Count - 1, I disable the corresponding button.

Piece of cake.


kaisersoze said:
1. The user selects one row
2. there will be up arrow and down arrow.
3. If the user wants to move up, the user clicks up arrow button
4. If the user wants to move down, then the user clicks down arrow button
5. if the row is at the top then up arrow button becomes disabled
6. if the row is at the bottom then down arrow button becomes disabled
 
Back
Top