|
-
Feb 9th, 2008, 01:23 AM
#1
Thread Starter
Member
Last edited by rhijaen; Feb 10th, 2008 at 02:04 AM.
-
Feb 9th, 2008, 01:04 PM
#2
Frenzied Member
Re: [2008] Stop activecontrol checkbox from becoming checked
You can either make the checkbox's Enabled property False, or its Checked property False. Both should work, but in order to give a better solution you need to provide us with more info on EXACTLY what you want to do and when to do it.
-
Feb 9th, 2008, 01:27 PM
#3
Re: [2008] Stop activecontrol checkbox from becoming checked
Your exact problem is not clear to me but you've said you want youre checkbox to remain unchecked (strange but everthing goes nah?)
Step 1 make a boolean on formlevel CheckChangeInprocess
this boolean flags if you are already busy in a check changed event so you don't run the event triggering it again
Watch this:
Code:
Dim CheckChangeInprocess as boolean
Private Sub chkAir_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkDustDevil.CheckedChanged, chkLightningBolt.CheckedChanged, 'etc etc
if CheckChangeInprocess then exit sub
CheckChangeInprocess = True
chkboxstatus()
CheckChangeInprocess = False
End Sub
Private Sub chkboxstatus()
If ActiveControl.Tag = "c" Then
txtCharSkillPts.Text = txtCharSkillPts.Text + txtSpellSkillPts.Text
ActiveControl.Tag = "u"
Else
If txtCharSkillPts.Text >= txtSpellSkillPts.Text Then
txtCharSkillPts.Text = txtCharSkillPts.Text - txtSpellSkillPts.Text
ActiveControl.Tag = "c"
Else
chkAir_CheckedChanged.Checked = False
End If
End If
End Sub
the boolean CheckChangeInprocess prevents triggering the code to run again when you set the checkbox.check to false
 why can't programmers keep and 31 Oct and 25 dec apart. Why Rating is Useful
for every question you ask provide an answer on another thread.
-
Feb 9th, 2008, 01:45 PM
#4
Re: [2008] Stop activecontrol checkbox from becoming checked
I'm not entirely sure what you mean but i think what you want to do is put this line in the Else statement:
vb Code:
DirectCast(ActiveControl, CheckBox).Checked = False
However, this may lead to problems so be careful.
I also notice you are doing maths on Strings... Shouldn't you be converting your values in the text property of the textboxes to Integers or Doubles (whichever suits).
-
Feb 9th, 2008, 11:43 PM
#5
Thread Starter
Member
Re: [2008] Stop activecontrol checkbox from becoming checked
Oh sorry I didn't explain myself clearly I guess..
In order to keep the code neater and not have hundreds of lines just for checkboxes, I have checkboxes grouped into groupboxes and am putting all the checkboxes in that group in the handles..
This is the full sub..
Code:
Private Sub chkAir_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkDustDevil.CheckedChanged, chkLightningBolt.CheckedChanged, chkWordofRecall.CheckedChanged, chkCallLightning.CheckedChanged, chkChainLightning.CheckedChanged, chkVortexofAir.CheckedChanged, chkNimbleness.CheckedChanged, chkElectricShield.CheckedChanged, chkStaticShield.CheckedChanged, chkInivisibility.CheckedChanged, chkSWGateway.CheckedChanged, chkHightowerGateway.CheckedChanged, chkMylanthiaGateway.CheckedChanged, chkTornado.CheckedChanged, chkHurricane.CheckedChanged, chkFogofIllusion.CheckedChanged, chkSuffocate.CheckedChanged, chkAirMasteryI.CheckedChanged, chkNimbusCloud.CheckedChanged
RetrievespellDetails(ActiveControl.Text)
chkboxstatus()
End Sub
So there is no checkbox named chkAir, just all the checkboxes are in the handle
 Originally Posted by stimbo
I'm not entirely sure what you mean but i think what you want to do is put this line in the Else statement:
vb Code:
DirectCast(ActiveControl, CheckBox).Checked = False
However, this may lead to problems so be careful.
I also notice you are doing maths on Strings... Shouldn't you be converting your values in the text property of the textboxes to Integers or Doubles (whichever suits).
Thank you, this seems to work well.
Last edited by rhijaen; Feb 9th, 2008 at 11:46 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|