• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 271
  • Last Modified:

Default Text Value of a CheckBox

I have a datagrid that displays a boolean field via a CheckBox.  When you click the check box the text changes from "false" to "true"; nothing complicated.  

Is there a way to change this to display something like "complete" and "incomplete" instead?
  • 3
1 Solution
The easiest way is to shrink the size of the text next to the checkbox and add your own label, then intercept the Checkbox's Change event and have it fill the desired text into the label depending on the value:

    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        If CheckBox1.Checked Then
            Label1.Text = "complete"
            Label1.Text = "incomplete"
        End If
    End Sub

You could even have the label autoalign itself over the label portion of the checkbox in the load process, but it's probably easiest by hand unless you're auto-sizing parts when the form changes size.
freethinker23Author Commented:
How do you shrink the size of the text next to the checkbox?
What I meant was to simply resize the control so the text does not show.

For example, set the checkbox control's width to  16 and the text should be hidden.  You may also be able set the text property = blank.

However, if you overlay the label, you don't necessarily need to do that.  And set the label's TextAlign property to middle-left for nice alignment.

Thanks for the points!
actually, don't change the text property since that may update the database...
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now