ToolStripButton::CheckedChanged Event

 

Occurs when the value of the Checked property changes.

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

public:
event EventHandler^ CheckedChanged {
	void add(EventHandler^ value);
	void remove(EventHandler^ value);
}

For more information about handling events, see Handling and Raising Events.

The following code example sets the CheckOnClick property to true and uses the Checked property in a CheckedChanged event to change the font of the button text to bold when the button is clicked.

ToolStripButton^ boldButton;

void InitializeBoldButton()
{
    boldButton = gcnew ToolStripButton;
    boldButton->Text = "B";
    boldButton->CheckOnClick = true;
    boldButton->CheckedChanged  += gcnew EventHandler(this, 
        &Form1::boldButtonCheckedChanged);
    toolStrip1->Items->Add(boldButton);
}

void boldButtonCheckedChanged(Object^ sender, EventArgs^ e)
{
    if (boldButton->Checked)
    { 
        this->Font= gcnew System::Drawing::Font(this->Font, 
            FontStyle::Bold);
    }
    else
    { 
        this->Font = gcnew System::Drawing::Font(this->Font, 
            FontStyle::Regular);
    }
}


//   internal:

.NET Framework
Available since 2.0
Return to top
Show: