Reputation: 1546
I'm using UltraWin Grid 12 (Infragistics) for Win Forms (vb.net 2010 Framework 3.5) .
Is there a way to hide all rows and only show the filtered In rows?. I need to show nothing unless a filter is selected, and when all filters are unselected, hide all rows again.
I tried a For Each ... row.hidden = true, but no luck.
Upvotes: 1
Views: 1727
Reputation: 3228
You can use a draw filter to hide all of the rows when there aren't any that are filtered out:
public class HideRowsDrawFilter:IUIElementDrawFilter
{
private UltraGrid grid;
public HideRowsDrawFilter(UltraGrid grid)
{
this.grid = grid;
}
public bool DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams)
{
if (this.grid.DisplayLayout.Rows.GetFilteredOutNonGroupByRows().Length == 0)
return true;
return false;
}
public DrawPhase GetPhasesToFilter(ref UIElementDrawParams drawParams)
{
if (drawParams.Element is RowUIElement)
return DrawPhase.BeforeDrawElement;
return DrawPhase.None;
}
}
To set the draw filter of the grid, use the following:
this.ultraGrid1.DrawFilter = new HideRowsDrawFilter(this.ultraGrid1);
Note that this only prevents drawing of the rows and they are still there so unless you disable them in another way, selection, editing, and activation will still happen.
Upvotes: 1
Reputation: 581
Cant u just set the default size to 0 ?
myGrid.Rows.DefaultSize = 0
myGrid.Refresh()
And when ever you are done getting the filters you need, just add the rows later. And when unselected just put your defaultsize again.
Upvotes: 0