Share via


DataGridViewRow.ReadOnly 屬性

定義

取得或設定值,指出資料列是否為唯讀。

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

屬性值

Boolean

如果屬性是唯讀,則為 true,否則為 false

屬性

例外狀況

資料列位於 DataGridView 控制項中而且是一個共用資料列。

範例

下列程式碼範例示範如何使用 DataGridViewBand.ReadOnly 屬性,這與 類別的 DataGridViewRow 屬性幾乎相同 ReadOnly 。 此程式碼範例是針對 類別提供的較大範例的 DataGridViewBand 一部分。

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

備註

屬性 ReadOnly 會影響 DataGridViewCell.ReadOnly 資料列中每個儲存格的屬性。

如果 屬性的值 DataGridView.ReadOnlytrue ,則設定這個屬性沒有任何作用。

適用於

另請參閱