CheckBox change state when label clicked (1 Viewer)

coatse

Registered User.
Local time
Today, 04:38
Joined
Jun 4, 2016
Messages
15
Howdy All,

I need to link labels to a checkbox so when the label is clicked it will change the checkbox. I know i can do this by adding a checkbox using the designer view by default but I can't use a click event on that type of label. When the checkbox is checked I want the label background to change to Green.

Thanks in advance

Jimmy;);):banghead:
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 06:38
Joined
Feb 28, 2001
Messages
26,996
FIRST: Note that your statement starts out by saing 'when the label is clicked it will change the checkbox' but then later you say 'when the checkbox is checked I want the label background to change to Green'. Which is it?

Now, assuming you can figure out what you wanted to do here, ...

When you create a bindable control having a label, that control becomes the parent of the label. Therefore it is possible to write a little subroutine that if you give it the bindable control name, it can loop through the controls on the form (For Each ctlobj In Me.Controls) and look for a control whose parent is the control in question.

Once you know the relationship, you SHOULD be able to have an OnClick event fire on either the label OR the bindable control. But if you prefer (and if it is that you want the label to change when the checkbox is checked), you could also use the LostFocus event to write an If/Then/Else/End If statement to set the color of the label directly.
 

coatse

Registered User.
Local time
Today, 04:38
Joined
Jun 4, 2016
Messages
15
FIRST: Note that your statement starts out by saing 'when the label is clicked it will change the checkbox' but then later you say 'when the checkbox is checked I want the label background to change to Green'. Which is it?

Now, assuming you can figure out what you wanted to do here, ...

When you create a bindable control having a label, that control becomes the parent of the label. Therefore it is possible to write a little subroutine that if you give it the bindable control name, it can loop through the controls on the form (For Each ctlobj In Me.Controls) and look for a control whose parent is the control in question.

Once you know the relationship, you SHOULD be able to have an OnClick event fire on either the label OR the bindable control. But if you prefer (and if it is that you want the label to change when the checkbox is checked), you could also use the LostFocus event to write an If/Then/Else/End If statement to set the color of the label directly.

Hi, yes you are correct this is two questions.

1) I want when a user clicks the label it will check the checkbox
2) Once the checkbox is clicked after the first action it will change the colour of the label to green

Jimmy
 

coatse

Registered User.
Local time
Today, 04:38
Joined
Jun 4, 2016
Messages
15
That's very simple to do...you do nothing! That is the default action on clicking on the label!

Linq ;0)>

Yes I know this is but if I use this I am unable to use a onclick event its does not give me these options. So I need to use a normal label that I want the checkbox to link to and change the colour of the label.
 

Users who are viewing this thread

Top Bottom