Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

This problem is simple and yet the answer eludes me.

 

I have a custom procedure that I call on the formload. basically if the checkbox is checked, then disable all the buttons, else enable them all. This seems to work when the form loads, it is unchecked. but when I check it again, the buttons are still enabled. I have a similar thing on the main form, except it will constantly check and do what the entire if then statement says.

 

What am I doing wrong? code below

 

Private Sub DefaultCheck()
       If ckdefault.Checked = True Then
           emlclr.Enabled = False
           navclr.Enabled = False
           sysclr.Enabled = False
           ctrlclr.Enabled = False
           frmclr.Enabled = False
           infoclr.Enabled = False
           lblbkclr.Enabled = False
       Else
           emlclr.Enabled = True
           navclr.Enabled = True
           sysclr.Enabled = True
           ctrlclr.Enabled = True
           frmclr.Enabled = True
           infoclr.Enabled = True
           lblbkclr.Enabled = True
       End If
   End Sub

 

I call this sub in the Form_load.

Posted
This problem is simple and yet the answer eludes me.

 

I have a custom procedure that I call on the formload. basically if the checkbox is checked, then disable all the buttons, else enable them all. This seems to work when the form loads, it is unchecked. but when I check it again, the buttons are still enabled. I have a similar thing on the main form, except it will constantly check and do what the entire if then statement says.

 

What am I doing wrong? code below

 

Private Sub DefaultCheck()
       If ckdefault.Checked = True Then
           emlclr.Enabled = False
           navclr.Enabled = False
           sysclr.Enabled = False
           ctrlclr.Enabled = False
           frmclr.Enabled = False
           infoclr.Enabled = False
           lblbkclr.Enabled = False
       Else
           emlclr.Enabled = True
           navclr.Enabled = True
           sysclr.Enabled = True
           ctrlclr.Enabled = True
           frmclr.Enabled = True
           infoclr.Enabled = True
           lblbkclr.Enabled = True
       End If
   End Sub

 

I call this sub in the Form_load.

 

Hi

 

Are you saying that when you 'Check' the ckdefault checkbox at design time and then run the application that the code fails or when you click the ckdefault check box at run time?

 

If the answer is run time are you calling the 'DefaultCheck' procedure from the CheckChanged event?

 

You could also use less lines of code like this:

 

emlclr.Enabled = Not ckdefault.Checked

navclr.Enabled = Not ckdefault.Checked

sysclr.Enabled = Not ckdefault.Checked

ctrlclr.Enabled = Not ckdefault.Checked

frmclr.Enabled = Not ckdefault.Checked

infoclr.Enabled = Not ckdefault.Checked

lblbkclr.Enabled = Not ckdefault.Checked

 

Cheers

CM :rolleyes:

Posted

At run time, if I change the status of ckdefault it does not execute the conditions. I can see why it's doing this, but I don't see how I can keep the script active without getting myself into a neverending loop or something.

 

What's weird is that I have something like this in another place in my app and i don't have a problem with it :(

  • *Experts*
Posted
One thought is to either put the DefaultCheck code in the check box's click sub or call the DefaultCheck sub from the check box's click sub as code mechanic suggested.

Member, in good standing, of the elite fraternity of mentally challenged programmers.

 

Dolphins Software

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...