I have a grid with 100's of rows and when i want to preselect a row I am setting the ActiveRow property and setting the Row selected property to True (see below) but I want the selected row to be visible on the screen and it appears to scroll close to it but the selected row is one row below the visible display. How can I move that selected row to the middle or top or just visible to the grid.
ugReleases.ActiveRow = rowueryStringSelectedrowQueryStringSelected.Selected = True
Thanks
Scott
ultraGrid1.ActiveRowScrollRegion.ScrollRowIntoView(ultraGrid1.ActiveRow);
Unfortuantely, this did not seem to change anything (and I did change the name of ultraGrid1 to the name of my grid) and the ActiveRow is being set before I called this. Any other ideas?
I am using 10.2 (10.2.20102.1004). It appears to me that the ActiveRow is being set and moved to one row at the bottom just out of visible view. If i scroll up one row, I can see the active row selected. Is it possible that the viewable area is hidden by one row? What should the behavior be in that should it move it to the top of the viewable area? Is there any way to programmatically set the activerow to be at the top of the viewable area? It is part of a larger project so hard to break it out into its own code.
Hi Scott,
Setting the ActiveRow property should scroll the row into view. If that's not happening, then it's probably an issue of timing. You may be setting the ActiveRow too early (before all the grid rows have been created, for example), or maybe you are setting it and then your code is doing something after you set it that changes the scroll position of the grid.
In what event are you setting the ActiveRow?
I am setting it on the form load event because i am passing some parameters to that form event. Is there a better event i can set it at?
Assuming you are setting the ActiveRow after you set the DataSource on the grid, then that's probably okay. But I'm still betting that something that occurs after that is changing it. Maybe something in the InitializeLayout or InitializeRow event of the grid. Are you handling either of those events? If so, can you post your code so I can take a look and see if anything in there might be changing the scroll position.
Another thing to try would be to use a BeginInvoke to call a method that sets the ActiveRow instead of doing it directly inside the Form_Load. That should create enough of a delay to get around any timing issues.
I don't have any code in InitializeLayout or InitializeRow. The only other places I am calling .ActiveRow is in ugReleases_AfterRowActivate and ugReleases_MouseUp.
I tried using BeginInvoke and it was the same behavior.
What should the behavior be in that should it move it to the top of the viewable area? Is there any way to programmatically set the activerow to be at the top of the viewable area?
By default, the grid just brings the ActiveRow into view. There's no guarantees about where within the view it appears.
If you want to make it the first visible row, then what you would do is set grid.ActiveRowScrollRegion.FirstRow to the row you want.
Perhaps this will give you better results than simply setting the ActiveRow, but I am curious as to why it's not working. If you can reproduce the behavior you are getting in a small sample project and post it here, I'd be glad to take a look at it.