DataGrid.CaptionVisibleChanged Event

Definition

Occurs when the CaptionVisible property has changed.

C#
public event EventHandler CaptionVisibleChanged;

Event Type

Examples

The following code example demonstrates the use of this event.

C#
// Create an instance of the 'CaptionVisibleChanged' EventHandler.
private void CallCaptionVisibleChanged()
{
   myDataGrid.CaptionVisibleChanged += 
                           new EventHandler(Grid_CaptionVisibleChanged);
}

// Set the 'CaptionVisible' property on click of a button.
private void myButton_Click(object sender, EventArgs e)
{
   if (myDataGrid.CaptionVisible)
      myDataGrid.CaptionVisible = false;
   else
      myDataGrid.CaptionVisible = true;
}

// Raise the event when 'CaptionVisible' property is changed.
private void Grid_CaptionVisibleChanged(object sender, EventArgs e)
{
   // String variable used to show message.
   string myString = "CaptionVisibleChanged event raised, caption is";
   // Get the state of 'CaptionVisible' property.
   bool myBool = myDataGrid.CaptionVisible;
   // Create appropriate alert message.
   myString += (myBool ? " " : " not ") + "visible";
   // Show information about caption of DataGrid. 
   MessageBox.Show(myString, "Caption information");
}

Applies to

Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0