DataGridViewRow.Frozen Właściwość

Definicja

Pobiera lub ustawia wartość wskazującą, czy wiersz jest zamrożony.

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

Wartość właściwości

Boolean

true jeśli wiersz jest zamrożony; w przeciwnym razie , false.

Atrybuty

Wyjątki

Wiersz znajduje się w kontrolce DataGridView i jest udostępnionym wierszem.

Przykłady

W poniższym przykładzie kodu pokazano, jak używać DataGridViewBand.Frozen właściwości, która jest niemal identyczna z Frozen właściwością DataGridViewRow klasy. Ten przykład kodu jest częścią większego przykładu podanego DataGridViewBand dla klasy.

// 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

Uwagi

Ta właściwość umożliwia przechowywanie jednego lub kilku wierszy ważnych informacji, gdy użytkownik przewija element DataGridView. Wszystkie wiersze powyżej zamrożonego wiersza są również zamrożone.

Dotyczy

Zobacz też