Bagikan melalui


DataGridViewRowPostPaintEventArgs.State Properti

Definisi

Mendapatkan status saat ini DataGridViewRow.

public:
 property System::Windows::Forms::DataGridViewElementStates State { System::Windows::Forms::DataGridViewElementStates get(); };
public System.Windows.Forms.DataGridViewElementStates State { get; }
member this.State : System.Windows.Forms.DataGridViewElementStates
Public ReadOnly Property State As DataGridViewElementStates

Nilai Properti

Kombinasi bitwise dari DataGridViewElementStates nilai yang menentukan status baris.

Contoh

Contoh kode berikut menunjukkan cara menggunakan State properti untuk menentukan apakah baris saat ini dipilih. Variabel, e, berjenis DataGridViewRowPostPaintEventArgs. Contoh kode ini adalah bagian dari contoh yang lebih besar yang disediakan dalam Cara: Menyesuaikan Tampilan Baris di Kontrol DataGridView Formulir Windows.

// Determine the foreground color.
if ((e.State & DataGridViewElementStates.Selected) ==
    DataGridViewElementStates.Selected)
{
    forebrush = new SolidBrush(e.InheritedRowStyle.SelectionForeColor);
}
else
{
    forebrush = new SolidBrush(e.InheritedRowStyle.ForeColor);
}
' Determine the foreground color.
If (e.State And DataGridViewElementStates.Selected) = _
    DataGridViewElementStates.Selected Then

    forebrush = New SolidBrush(e.InheritedRowStyle.SelectionForeColor)
Else
    forebrush = New SolidBrush(e.InheritedRowStyle.ForeColor)
End If

Keterangan

Properti ini dapat digunakan untuk menentukan apakah baris dibekukan, baca-saja, atau dipilih, di antara status lainnya.

Berlaku untuk

Lihat juga