Version

Hiding Columns and Groups

To hide a column at design time:

  1. If your grid has a DataSource set up at Design-time, you can hide columns or groups in the property pages.

    Open the property pages by selecting the grid on the form and clicking the Custom Properties…​ link at the bottom of the Properties window.

  2. Switch to the Groups and Columns tab.

  3. Select the Column or Group you want to hide from the tree list.

  4. Click the Show/Hide button.

  5. Set the Hidden property.

To hide a column at run time:

In Visual Basic:

Private Sub Hide_Columns_and_Groups_Load(ByVal sender As System.Object, _
  ByVal e As System.EventArgs) Handles MyBase.Load
	Me.UltraGrid1.DisplayLayout.Bands(0).Columns(0).Hidden = True
End Sub

In C#:

private void Hide_Columns_and_Groups_Load(object sender, EventArgs e)
{
	this.ultraGrid1.DisplayLayout.Bands[0].Columns[0].Hidden = true;
}

ColPosChanged Events

When the user hides or unhides a column via the UI, the BeforeColPosChanged and AfterColPosChanged events fire. Likewise, if the user hides/unhides an UltraGridGroup the BeforeGroupPosChanged and AfterGroupPosChanged fire.

To listen for this interaction, you can trap for when the ColumnPosChangedType is PosChangedType.HiddenStateChanged in the event arguments, as demonstrated in the following code:

In C#

private void UltraGrid1_AfterColPosChanged(object sender, AfterColPosChangedEventArgs e)
{
    bool hasHiddenChanged = (e.ColumnPosChangedType & PosChangedType.HiddenStateChanged)
        == PosChangedType.HiddenStateChanged;
    if(hasHiddenChanged)
    {
        //YOUR CODE HERE
    }
}

In VB

Private Sub UltraGrid1_AfterColPosChanged(sender As Object, e As AfterColPosChangedEventArgs)
    Dim hasHiddenChanged As Boolean = (e.ColumnPosChangedType And PosChangedType.HiddenStateChanged) = PosChangedType.HiddenStateChanged
    If hasHiddenChanged Then
        'YOUR CODE HERE
    End If
End Sub