Export (0) Print
Expand All

DataGrid.CaptionVisibleChanged Event

Occurs when the CaptionVisible property has changed.

[Visual Basic]
Public Event CaptionVisibleChanged As EventHandler
[C#]
public event EventHandler CaptionVisibleChanged;
[C++]
public: __event EventHandler* CaptionVisibleChanged;

[JScript] In JScript, you can handle the events defined by a class, but you cannot define your own.

Event Data

The event handler receives an argument of type EventArgs.

Remarks

For more information about handling events, see Consuming Events.

Example

[Visual Basic] 
' Create an instance of the 'CaptionVisibleChanged' EventHandler.
Private Sub CallCaptionVisibleChanged()
   AddHandler myDataGrid.CaptionVisibleChanged, AddressOf Grid_CaptionVisibleChanged
End Sub 'CallCaptionVisibleChanged


' Set the 'CaptionVisible' property on click of a button.
Protected Sub myButton_Click(sender As Object, e As EventArgs)
   If myDataGrid.CaptionVisible = True Then
      myDataGrid.CaptionVisible = False
   Else
      myDataGrid.CaptionVisible = True
   End If
End Sub 'myButton_Click
 
' Raise the event when 'CaptionVisible' property is changed.
Protected Sub Grid_CaptionVisibleChanged(sender As Object, e As EventArgs)
   ' String variable used to show message.
   Dim myString As String = "CaptionVisibleChanged event raised, caption is"
   ' Get the state of 'CaptionVisible' property.
   Dim myBool As Boolean = myDataGrid.CaptionVisible
   ' Create appropriate alert message.
   myString +=IIf(myBool ," " , " not ") + "visible" 
   ' Show information about caption of DataGrid. 
   MessageBox.Show(myString, "Caption information")
End Sub 'Grid_CaptionVisibleChanged


[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.
protected void myButton_Click(object sender, EventArgs e)
{
   if (myDataGrid.CaptionVisible == true)
      myDataGrid.CaptionVisible = false;
   else
      myDataGrid.CaptionVisible = true;
}

// Raise the event when 'CaptionVisible' property is changed.
protected 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");
}

[C++] 
// Create an instance of the 'CaptionVisibleChanged' EventHandler.
private:
void CallCaptionVisibleChanged() {
    myDataGrid->CaptionVisibleChanged += 
        new EventHandler(this, &MyDataGrid::Grid_CaptionVisibleChanged);
}

// Set the 'CaptionVisible' property on click of a button.
protected:
void myButton_Click(Object* /*sender*/, EventArgs* /*e*/) {
    if (myDataGrid->CaptionVisible == true)
        myDataGrid->CaptionVisible = false;
    else
        myDataGrid->CaptionVisible = true;
}

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

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

DataGrid Class | DataGrid Members | System.Windows.Forms Namespace

Show:
© 2014 Microsoft