DataGridColumnStyle.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.

private void Button_Click(Object sender, EventArgs e)
{ 
   if (myButton.Text == "Make column read/write")
   {
      myDataGridColumnStyle.ReadOnly = false;
      myButton.Text = "Make column read only";
   }
   else
   {
      myDataGridColumnStyle.ReadOnly = true;
      myButton.Text = "Make column read/write";
   }
}

private void AddCustomDataTableStyle()
{
   myDataGridTableStyle = new DataGridTableStyle();
   myDataGridTableStyle.MappingName = "Customers";
   myDataGridColumnStyle = new DataGridTextBoxColumn();
   myDataGridColumnStyle.MappingName= "CustName";
   // Add EventHandler function for readonlychanged event.
   myDataGridColumnStyle.ReadOnlyChanged += new EventHandler(myDataGridColumnStyle_ReadOnlyChanged);
   myDataGridColumnStyle.HeaderText = "Customer";
   myDataGridTableStyle.GridColumnStyles.Add(myDataGridColumnStyle);
   // Add the 'DataGridTableStyle' instance to the 'DataGrid'.
   myDataGrid.TableStyles.Add(myDataGridTableStyle);
}
private void myDataGridColumnStyle_ReadOnlyChanged(Object sender, EventArgs e)
{
   MessageBox.Show("'Readonly' property is changed");
}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft