Contrary to popular belief, there are three states that a checkbox can have:
- Checked
- Unchecked
- Undertermined
When you click, you only get the first two states. When you use the spacebar, you can get all three.
You can fix with with code in the KeyPress event:
IF (nKeyCode = 32)
This.Value = !This.Value
ThisForm.Refresh()
ENDIF
The code to enable/disable other controls should be moved to the Form.Refresh method.
This.txtlimitedby.Enabled = This.Chkbox.Value
This.limiteddays.Enabled = This.Chkbox.Value
>Hi Gang!
>
>Question here.....
>
>We have a form that is used for configuring the POS system we support.
>
>We have lots of checkboxes on this form.
>
>We added a textbox and a label beside one of the checkboxes.
>
>When you click this checkbox, it enables and disables them according to the click you just did....
>
>checkbox.click
>
>IF this.Value
> this.parent.txtlimitedby.ENABLED =.T.
> this.Parent.limiteddays.ENABLED = .T.
>ELSE
> this.parent.txtlimitedby.ENABLED =.F.
> this.Parent.limiteddays.ENABLED = .F.
>ENDIF
>THISFORM.REFRESH
>
>
>This works great with the textbox and the label.....
>
>But when you press the spacebar, when the checkbox has a checkmark, the checkbox does not change, but the textbox and the label but disable and will not reenable.
>
>And if you press the spacebar, when the checkbox does not have a checkmar, the checkbox does not change, but the textbox and the lablel then enable and will not disable.
>
>Ok... what am I obviously overlooking?
>
>Thanks!
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer