DataGridViewColumn.Visible 属性


获取或设置一个值,该值指示该列是否可见。Gets or sets a value indicating whether the column is visible.

 virtual property bool Visible { bool get(); void set(bool value); };
public override bool Visible { get; set; }
member this.Visible : bool with get, set
Public Overrides Property Visible As Boolean


如果该列可见,则为 true;否则为 falsetrue if the column is visible; otherwise, false.


下面的代码示例演示如何使用 DataGridViewBand.Visible 属性,该属性与 DataGridViewColumn 类的 Visible 属性几乎完全相同。The following code example demonstrates how to use the DataGridViewBand.Visible property, which is nearly identical to the Visible property of the DataGridViewColumn class. 此代码示例是为 DataGridViewBand 类概述提供的更大示例的一部分。This code example is part of a larger example provided for the DataGridViewBand class overview.

// Hide a band of cells.
void Button6_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
   DataGridViewBand^ band = dataGridView->Rows[ 3 ];
   band->Visible = false;

// Hide a band of cells.
private void Button6_Click(object sender, System.EventArgs e)

    DataGridViewBand band = dataGridView.Rows[3];
    band.Visible = false;
' Hide a band of cells.
Private Sub Button6_Click(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles Button6.Click

    Dim band As DataGridViewBand = dataGridView.Rows(3)
    band.Visible = False
End Sub


使用此属性可以在将列保存在 DataGridView中的同时,隐藏列。Use this property to hide a column from view while keeping the column in the DataGridView. 若要完全删除某一列,请使用 DataGridViewColumnCollection.Remove 方法。To completely remove a column, use the DataGridViewColumnCollection.Remove method.

若要隐藏在绑定到数据源时自动生成的列,请在 DataBindingComplete 事件处理程序中设置此属性。To hide a column that is automatically generated when binding to a data source, set this property in a DataBindingComplete event handler.