DataGridViewBand.ReadOnly 属性     
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置一个值,该值指示用户是否可以编辑带区的单元格。
public:
 virtual property bool ReadOnly { bool get(); void set(bool value); };public virtual bool ReadOnly { get; set; }member this.ReadOnly : bool with get, setPublic Overridable Property ReadOnly As Boolean属性值
如果用户不能编辑带区的单元格,则为 true,否则为 false。 默认值为 false。
例外
设置此属性时,此 DataGridViewBand 实例为共享的 DataGridViewRow。
示例
下面的代码示例演示如何使用 ReadOnly 属性来禁用整个 DataGridView编辑。 此代码示例是为 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 带中每个单元格的属性。 例如,如果 ReadOnly 更改的属性 DataGridViewRow ,则 DataGridViewCell.ReadOnly 行中的所有单元格的属性将更改。