ToolStripButton.Checked Propriedade
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Recebe ou define um valor que indica se o ToolStripButton é pressionado ou não.
public:
property bool Checked { bool get(); void set(bool value); };
public bool Checked { get; set; }
member this.Checked : bool with get, set
Public Property Checked As Boolean
Valor de Propriedade
true se o ToolStripButton for pressionado ou não pressionado; caso contrário, false. A predefinição é false.
Exemplos
O exemplo de código seguinte define a CheckOnClick propriedade para true e usa a Checked propriedade num CheckedChanged evento para alterar a fonte do texto do botão para negrito quando o botão é clicado.
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:
internal ToolStripButton boldButton;
private void InitializeBoldButton()
{
boldButton = new ToolStripButton();
boldButton.Text = "B";
boldButton.CheckOnClick = true;
toolStrip1.Items.Add(boldButton);
}
private void boldButton_CheckedChanged(object sender, EventArgs e)
{
if (boldButton.Checked)
{
this.Font = new Font(this.Font, FontStyle.Bold);
}
else
{
this.Font = new Font(this.Font, FontStyle.Regular);
}
}
Friend WithEvents boldButton As ToolStripButton
Private Sub InitializeBoldButton()
boldButton = New ToolStripButton()
boldButton.Text = "B"
boldButton.CheckOnClick = True
toolStrip1.Items.Add(boldButton)
End Sub
Private Sub boldButton_CheckedChanged(ByVal sender As [Object], _
ByVal e As EventArgs) Handles boldButton.CheckedChanged
If boldButton.Checked Then
Me.Font = New Font(Me.Font, FontStyle.Bold)
Else
Me.Font = New Font(Me.Font, FontStyle.Regular)
End If
End Sub