How can I determine if grid is scrolled to the end (thumb is at the bottom of a scroll bar)?
Assuming that your grid is flat (no child bands or grouping, then you can try something like this:
RowScrollRegion rowScrollRegion = this.ultraGrid1.ActiveRowScrollRegion; UltraGridRow lastVisibleRowInRowScrollRegion = null; for (int i = rowScrollRegion.VisibleRows.Count - 1; i >= 0; i--) { UltraGridRow row = rowScrollRegion.VisibleRows[i].Row; UIElement rowElement = row.GetUIElement(rowScrollRegion); if (rowElement != null && rowElement.Parent.Rect.Bottom > rowElement.Rect.Bottom) { lastVisibleRowInRowScrollRegion = row; break; } } UltraGridRow lastRowInGrid = null; for (int i = this.ultraGrid1.Rows.Count - 1; i >= 0; i--) { UltraGridRow row = this.ultraGrid1.Rows[i]; if (false == row.HiddenResolved) { lastRowInGrid = row; break; } } MessageBox.Show(this, "Scrolled to Bottom: " + (lastRowInGrid == lastVisibleRowInRowScrollRegion).ToString());
In my case ScrollBounds is set to ScrollToFill. So I'll stop to search for a solution. Thank you, Mike.
Out of curiosity... why would you need to know when the scroll bar is at the bottom?
If the grid's ScrollBounds is set to the default, then when the scroll bar is at the bottom, there will be only one row visible in the ActiveRowScrollRegion and it will be the last (visible) row of data. So that should be fairly easy to detect.
If ScrollBounds is set to ScrollToFill, then I don't see any easy way to do this.
Alan, I've tested you method and it's also not very accurate - when grid is scrolled to the bottom I always get ScrollPosition + VisibleRows.Count = DataSet.Rows.Count and it's the equal even if scroll is "one click before" it's maximum value. So, it doesn't work for me.
So, I got another question is there anyway to get vertical scrollbar Maximum value?
Amiram, definitely not. Because rect height is a value in pixels and ScrollPosition value is between 0 and data items count.