Bagikan melalui


DataGridViewRow.ReadOnly Properti

Definisi

Mendapatkan atau menetapkan nilai yang menunjukkan apakah baris bersifat baca-saja.

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

Nilai Properti

true jika baris bersifat baca-saja; jika tidak, false.

Atribut

Pengecualian

Baris berada dalam DataGridView kontrol dan merupakan baris bersama.

Contoh

Contoh kode berikut menunjukkan cara menggunakan DataGridViewBand.ReadOnly properti , yang hampir identik ReadOnly dengan properti DataGridViewRow kelas . Contoh kode ini adalah bagian dari contoh yang lebih besar yang disediakan untuk DataGridViewBand kelas .

// Make the entire DataGridView read only.
void Button8_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
   System::Collections::IEnumerator^ myEnum = dataGridView->Columns->GetEnumerator();
   while ( myEnum->MoveNext() )
   {
      DataGridViewBand^ band = safe_cast<DataGridViewBand^>(myEnum->Current);
      band->ReadOnly = true;
   }
}
// Make the entire DataGridView read only.
private void Button8_Click(object sender, System.EventArgs e)
{
    foreach (DataGridViewBand band in dataGridView.Columns)
    {
        band.ReadOnly = true;
    }
}
' Make the entire DataGridView read only.
Private Sub Button8_Click(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles Button8.Click

    For Each band As DataGridViewBand In dataGridView.Columns
        band.ReadOnly = True
    Next
End Sub

Keterangan

Properti ReadOnly memengaruhi DataGridViewCell.ReadOnly properti setiap sel dalam baris.

Pengaturan properti ini tidak berpengaruh jika nilai DataGridView.ReadOnly properti adalah true.

Berlaku untuk

Lihat juga