I am using a checkbox as a toggle switch (ON-OFF Button) by changing its appearance to Button
using Checkbox.Appearance
property.
When I run the VB.NET application, the Checkbox
turns into a button only after the first click. Is it possible to change the appearance of the Checkbox
to button as default? I also want the button to Popup when the user clicks "ON". I have tried changing the appearance using FlatStyle
property, but it doesn't work.
I am using the following code:
Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
CheckBox1.Appearance = System.Windows.Forms.Appearance.Button
If CheckBox1.Checked = True Then
CheckBox1.Text = "ON"
ElseIf CheckBox1.Checked = False Then
CheckBox1.Text = "OFF"
End If
End Sub