I have a UltraWinGrid bound to a model(which holds the dataset) , through a BindingSource. I have 2 buttons, 'Up' and 'Down' to move rows in the grid. I want to move those rows in the underlying table also, but by using RefreshBinding or events,smth like that, not by moving the rows by code and then rebind the grid to the table. Pleas help, I've tried everything and it just move the selection in the grid.
Hi Yaju,
UltraWinGrid does not have any built-in support for paging. So I assume you are probably implementing it yourself by retrieving only the data for a single page at a time and binding that to the grid.
So the only way to get all of the rows would be to do it from your data source and get all the rows.
Hi Mike
I have a grid with paging enabled and i am moving the contents of grid to a temporary table
DataTable
();
dt.Columns.Add(
));
//DataRow row = dt.NewRow();
dgChoice.Rows)
{
row = dt.NewRow();
row[
].Value.ToString());
] = item.Index;
But only the rows of current page of the grid are getting copied not all the rows of the grid, is there any way by which i can copy all the rows of the grid to the temporary table?
Thanks
Yaju
Hi,
Trying simply that didn't work for me, as the row loses all of its ItemArray content after a call to Rows.Remore(row). I had to copy the contents of the cells in this row, remove the row, enter in edit mode, then copy the contents back to the row, and finally insert the row back in the dataset at another place.
What I did is (move row upwards) :
DataRow row = table.Rows[index];object[] rowArray = new object[nbColumns];row.ItemArray.CopyTo(rowArray, 0);table.Rows.Remove(row);row.BeginEdit();row.ItemArray = rowArray;row.EndEdit();table.Rows.InsertAt(row, index - 1);
Thanks Mike. I guess I have no other choice than move the rows in the DataTable myself :)
Moving rows in the DataTable is not something that the grid can do - that would have to be done in code. I'm not aware of any methods on the DataTable which make this easy to do. My guess is that you would have to remove the row from the data table and then re-insert it at the correct point.
I tried this out and the grid seems to update with the new order just fine - as long as the grid is not sorted.
For example, if my grid is bound to a DataTable called dt1, this moves row 2 to the first position in the table.
DataRow row = this.dt1.Rows[2]; this.dt1.Rows.Remove(row); this.dt1.Rows.InsertAt(row, 0);