Bagikan melalui


DataGridViewBand.ReadOnly Properti

Definisi

Mendapatkan atau menetapkan nilai yang menunjukkan apakah pengguna dapat mengedit sel pita.

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

Nilai Properti

true jika pengguna tidak dapat mengedit sel pita; jika tidak, false. Defaultnya adalah false.

Pengecualian

Saat mengatur properti ini, instans ini DataGridViewBand adalah berbagi DataGridViewRow.

Contoh

Contoh kode berikut menunjukkan cara menggunakan ReadOnly properti untuk menonaktifkan pengeditan untuk seluruh DataGridView. 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 pita. Misalnya, jika ReadOnly properti DataGridViewRow perubahan, properti DataGridViewCell.ReadOnly semua sel dalam baris akan berubah.

Berlaku untuk

Lihat juga