I will need to perform a scroll of the grid (right or left) without navigation through the cells. What I am trying to do is marked the group headers rows (using the backcolor) and when reaching the last visible cell in the grid I will like to scroll it. I will need to determine somehow that I have reach the last visible cell and maybe PerformAction(scroll)?? Is there a way to get the last group header/column visible and scroll it via PerfomrAction?
Thanks,
Mihail
Hi Mihail,
I'm not really sure what you mean by "group headers rows". But you can scroll the grid using methods on the grid.ActiveColScrollRegion. There are several methods on this object to scroll columns into view or control the scoll position of the grid.
To determine the last visible column in the grid, you can use the GetRelatedVisibleColumn method on the column.If you ask for the next column and it returns null, you know there isn't one.
Hi Mike:
Here is my code:
GroupColumnsCollection columns = nextGroup.Columns; if (columns.Count > 0) { //get the first and only column in the group and check if visible UltraGridColumn colingroup = columns[0]; UltraGridColumn col = colingroup.GetRelatedVisibleColumn(VisibleRelation.Next);
}
My group has one column per group, trying to see if next is visible. I am getting the next column, not a null even if the column is far right, outside of the visible area. Even if I check on VisibleRelation.Last I am getting the last column instead of an expected null.
Also true for the group:
UltraGridGroup visible = nextGroup.GetRelatedVisibleGroup(VisibleRelation.Next); if (visible == null) View.SmartGridExcel.ActiveColScrollRegion.Scroll(ColScrollAction.LineRight);
Any ideas?
I'm still not sure what the question / problem is. Everything you descrive here sounds correct.
In GetRelatedVisibleColumn, Visible means that the column is not hidden. It does not mean visible on the screen. If yuo want to check if the column is actually visible on the screen, then that's pretty tricky. You would have to use UIElement. You might be able to just check if the column.Header.GetUIElement method returns null, maybe.
What event are you using to check for the existance of the column header UIElement?
I would have though the Refresh would work. But if not, you might have to be more aggressive about forcing the grid to rebuild the UIElement structure. You could try something like:
grid.UIElement.DirtyChildElements(true)
grid.Invalidate()
grid.UIElement.VerifyChildElements()
grid.Refresh()
If that works, it is probably overkill and you can try removing some of those lines of code to see what combination you need.
If it doesn't work, then I'm not sure if what you want to do here is possible. You might need to use a different event, or it just may not be doable.
In both cases (either Refresh or VerifyChildElements) I am getting the same null for headers.GetUIElement() calls.
If the UIElement is still returning null for columns that are actually visible on the screen, the my guess is that you are doing the check synchronously and the grid hasn't had time to paint. So maybe if you call Refresh on the grid or maybe grid.DisplayLayout.UIElement.VerifyChildElements, you can force the creation of the elements before you check them.