DataGridViewColumn.ReadOnly Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan atau menetapkan nilai yang menunjukkan apakah pengguna dapat mengedit sel kolom.
public:
virtual property bool ReadOnly { bool get(); void set(bool value); };
public override bool ReadOnly { get; set; }
member this.ReadOnly : bool with get, set
Public Overrides Property ReadOnly As Boolean
Nilai Properti
true jika pengguna tidak dapat mengedit sel kolom; jika tidak, false.
Pengecualian
Properti ini diatur ke false untuk kolom yang terikat ke sumber data baca-saja.
Contoh
Contoh kode berikut menunjukkan cara menggunakan DataGridViewBand.ReadOnly properti , yang hampir identik ReadOnly dengan properti DataGridViewColumn kelas . Contoh kode ini adalah bagian dari contoh yang lebih besar yang disediakan untuk DataGridViewBand gambaran umum 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 kolom.