共用方式為


DataGridViewBand.Frozen 屬性

定義

取得或設定值,指出當使用者透過 DataGridView 捲動時,群組列是否會移動。

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

屬性值

Boolean

如果群組列不能從檢視位置捲動,則為 true,否則為 false。 預設為 false

範例

下列程式碼範例會凍結資料行和資料列中的儲存格帶。 此範例也會變更凍結帶的預設儲存格樣式,以指定凍結的帶狀。 此程式碼範例是提供給 類別之較大範例的 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 動 時,這個屬性可以保留一系列重要資訊。 與凍結帶連續的帶狀區會移到凍結的帶狀帶上方。

適用於

另請參閱