Default Text Value of a CheckBox

Posted on 2005-05-04
Last Modified: 2010-04-23
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?
Question by:freethinker23
    LVL 22

    Accepted 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.

    Author Comment

    How do you shrink the size of the text next to the checkbox?
    LVL 22

    Expert Comment

    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!
    LVL 22

    Expert Comment

    actually, don't change the text property since that may update the database...

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now