Background:I have an application that contains the UltraWinGrid, and there is enough data to cause a vertical scroll bar, thats fine, the scrolling works fine.
I want to double click rows form the UltraWinGrid to cause a showdialog of a form, works fine.
When the dialog form shows up, and I then close it, I re-assign the UltraWinGrid datasource from the database.
Problem:When I close the dialog form and re-assign the datasource from the DataTable, the UltraWinGrid goes back to the top, and ignores the fact that I had it scrolled down.
Can somebody please help me with this?
before you change the datasource save the following in a variable:
pos = ultraGrid1.Rows.IndexOf(ultraGrid1.ActiveRowScrollRegion.FirstRow);
after you change the datasource, set the following:
ultraGrid1.ActiveRowScrollRegion.FirstRow = ultraGrid1.Rows[pos];
Thanks guys, this works if there is no group by (without drag a column header here to group by that column).
Sorry, I didn't explain this in the original post.
I have "drag a column" enabled.
Is there a way to capture the expanded rows and then re-expand them again if they are still available?
i guess you can save the layout of the grid before setting the datasource to null, then load it after that. this will keep the grouping, sorting...
ultraGrid1.DisplayLayout.SaveAsXml(ms);
ultraGrid1.DataSource = null;
ultraGrid1.DataSource = dt;
ms.Position = 0;
ultraGrid1.DisplayLayout.LoadFromXml(ms);
but this wont re-expand the expanded rows.
i guess you should loop into them before and save the indexes of the expanded rows then loop again and re-expand them