DataGridViewRow.Frozen 属性

定义

获取或设置一个指示行是否已被冻结的值。

public:
 virtual property bool Frozen { bool get(); void set(bool value); };
[System.ComponentModel.Browsable(false)]
public override bool Frozen { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.Frozen : bool with get, set
Public Overrides Property Frozen As Boolean

属性值

如果行已被冻结,则为 true;否则为 false

属性

例外

行位于 DataGridView 控件中,并且是共享行。

示例

下面的代码示例演示如何使用 DataGridViewBand.Frozen 属性,该属性几乎与 类的 DataGridViewRow 属性相同Frozen。 此代码示例是为 DataGridViewBand 类提供的一个更大示例的一部分。

// Freeze the first row.
void Button4_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
   FreezeBand( dataGridView->Rows[ 0 ] );
}

void Button5_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
   FreezeBand( dataGridView->Columns[ 1 ] );
}

void FreezeBand( DataGridViewBand^ band )
{
   band->Frozen = true;
   DataGridViewCellStyle^ style = gcnew DataGridViewCellStyle;
   style->BackColor = Color::WhiteSmoke;
   band->DefaultCellStyle = style;
}
// Freeze the first row.
private void Button4_Click(object sender, System.EventArgs e)
{

    FreezeBand(dataGridView.Rows[0]);
}

private void Button5_Click(object sender, System.EventArgs e)
{

    FreezeBand(dataGridView.Columns[1]);
}

private static void FreezeBand(DataGridViewBand band)
{
    band.Frozen = true;
    DataGridViewCellStyle style = new DataGridViewCellStyle();
    style.BackColor = Color.WhiteSmoke;
    band.DefaultCellStyle = style;
}
' Freeze the first row.
Private Sub Button4_Click(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles Button4.Click

    FreezeBand(dataGridView.Rows(0))
End Sub

Private Sub FreezeColumn(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles Button5.Click

    FreezeBand(dataGridView.Columns(1))
End Sub

Private Shared Sub FreezeBand(ByVal band As DataGridViewBand)

    band.Frozen = True
    Dim style As DataGridViewCellStyle = New DataGridViewCellStyle()
    style.BackColor = Color.WhiteSmoke
    band.DefaultCellStyle = style

End Sub

注解

当用户滚动 DataGridView浏览 时,此属性允许你保留一行或多行重要信息。 冻结行上方的所有行也会被冻结。

适用于

另请参阅