DataGridViewRow.ReadOnly 属性     
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置一个值,指示行是否为只读。
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, setPublic Overrides Property ReadOnly As 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.ReadOnly 值为 ,则设置此属性 true不起作用。