Skip to main content

GridColumn.Visible Property

Gets or sets whether the grid column is visible.

Namespace: DevExpress.XtraGrid.Columns

Assembly: DevExpress.XtraGrid.v22.2.dll

NuGet Package: DevExpress.Win.Grid

Declaration

[DefaultValue(false)]
[DXCategory("Appearance")]
[XtraSerializableProperty]
[XtraSerializablePropertyId(3)]
public virtual bool Visible { get; set; }

Property Value

Type Default Description
Boolean false

true if the column is visible; otherwise, false.

Remarks

The Visible and GridColumn.VisibleIndex properties specify the column’s visible state and position. When you hide/show the column with the Visible property, the GridColumn.VisibleIndex property automatically reflects the changes. Similarly, if you toggle the column’s visibility with the GridColumn.VisibleIndex property, the Visible property changes automatically. See GridColumn.VisibleIndex to learn more.

The code sample below illustrates how to change grid column visibility based on the user’s permissions.

public class UserPermissions
{
    public bool canSeeProductId;
    public bool canSeeProductActions;
}

UserPermissions permissions = new UserPermissions();
permissions.canSeeProductId = false;
permissions.canSeeProductActions = false;

gridView1.Columns["productId"].Visible = permissions.canSeeProductId;
gridView1.Columns["productActions"].Visible = permissions.canSeeProductActions;
See Also