I have a grid that is disabled. The users would like a way to see all the data. Instead of enabling the grid and trying to turn off all the cells, I would like to give the users a way to trigger the grid to temporarily expand to fit. My current plan is to handle mouse move on the grid's parent control, and when the mouse moves over the grid trigger the expand and shrink again when they move off.
In order to do that, I need to know if all the columns are currently being displayed. Is there an easy way to determine if that is true?
I suppose one way of doing that would be to detect if the grid is showing a horizontal scroll bar...is that easy to determine?
Thanks
Hi,
The only way to tell if the Horizontal scrollbar is displayed is to use the grid's UIElements.
private void ultraGrid1_MouseMove(object sender, MouseEventArgs e) { UltraGrid grid = (UltraGrid)sender; UIElement element = grid.DisplayLayout.UIElement.GetDescendant(typeof(ColScrollbarUIElement)); if (element != null) Debug.WriteLine("Yes, the grid has a scrollbar."); else Debug.WriteLine("No, the grid has no scrollbar."); }
As for determining with width of all of the columns, this is extremely complicated. It depends on a wide range of factors including the RowLayoutMode and which features of you grid are enabled, and also property settings like CellPadding, CellSpacing, and the BorderStyle.
Assuming that all of these factors are fixed and will not change in your application, then you can probably figure it out using the Width property of each column and applying an adjustment for the RowSelectors and vertical scrollbar (if there is one).