DataGrid.ReadOnlyChanged Event


Occurs when the ReadOnly property value changes.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public event EventHandler ReadOnlyChanged

The following code example demonstrates the use of this member.

// Attach to event handler.
private void AttachReadOnlyChanged()
   this.myDataGrid.ReadOnlyChanged += new EventHandler(this.myDataGrid_ReadOnlyChanged);
// Check if the 'ReadOnly' property is changed.
private void myDataGrid_ReadOnlyChanged(object sender, EventArgs e)
   string strMessage = "false";
   if(myDataGrid.ReadOnly == true)
      strMessage = "true";

   MessageBox.Show("Read only changed to "+strMessage,
      "Message",   MessageBoxButtons.OK,
// Toggle the 'ReadOnly' property.
private void button2_Click(object sender, EventArgs e)
   if(myDataGrid.ReadOnly == true)
      myDataGrid.ReadOnly = false;
      myDataGrid.ReadOnly = true;

.NET Framework
Available since 1.1
Return to top