A checkbox that shows an X instead of a √ character


Q: I want my checkboxes to show X:s instead of a √. How can I achieve that?

A. There are a number of possible approaches to the problem
     - There may be a checkbox with this property on the market somewhere
     - You can build your own control
     - The simplest way is to use a text box control directly as shown below

Create a textbox control, with dimensions to simulate a checkbox. Try the following properties

 Property  Property Value
 Name  MyCheckbox1
 Height  240
 TabStop  No
 Width  240

Add a label, MyCheckBoxLabel1,  next to the textbox , and type the following code

Private Sub MyCheckBox1_Click()
  'If the user clicks the textbox, it shall switch between empty and "X"

  If Text1.Text = "X" Then
    Text1.Text = ""
  Else
    Text1.Text = "X"
  End If

  'Send focus away in order not to see the cursor
  Me.SetFocus
End Sub

Private Sub MyCheckBoxLabel1_Click()
  'A click on the label shall be received as a click on the textbox
  MyCheckBox1_Click
End Sub
 

To check whether the "checkbox" has been selected, you will of course have to check whether

    MyCheckBox1.Text = "X"