共用方式為


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

屬性值

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 時,此屬性可讓您保留一或多個重要資訊列。 凍結資料列上方的所有資料列也會凍結。

適用於

另請參閱