PDA

View Full Version : Checkbox to enable / dissable listboxes.


jpn5
01-06-2009, 10:00 PM
Hi Guys, This is probably a really stupid question but I've looked all over and can find a solution...

I have a couple of list boxes on my UI and each of them have a checkbox - which should be used to enable / disable the listbox. For some reason they have no effect.

I've tried fiddling with a few variations on the following but haven't had any joy.


on chkbx1 changed state do
(
if state == 1 then
(
LstBox1.enabled = true
LstBox2.enabled = false
)
else
(
LstBox2.enabled = true
)
)
on chkbx2 changed state do
(
if state == 1 then
(
LstBox2.enabled = true
LstBox1.enabled = false
)
else
(
LstBox2.enabled = true
)
)

Any help would be greatly appreciated.

JPN5

RobGalanakis
01-06-2009, 10:32 PM
State is true or false, not an integer. Thus you are always doing the 'else' code.

jpn5
01-06-2009, 11:42 PM
ah right, i thought you could use either true/false or 1/0 to define the state of a checkbox! i'll give it a try tomorrow using true/false instead though.

thanks for your help.

JPN5

magicm
01-06-2009, 11:55 PM
Since state is either true or false, you can set the .enabled properties of the listboxes directly using that value. The following code also checks/unchecks the opposite checkbox so they remain in sync:

on chkbx1 changed state do
(
LstBox1.enabled = state
LstBox2.enabled = chkbx2.checked = not state
)

on chkbx2 changed state do
(
LstBox1.enabled = chkbx1.checked = not state
LstBox2.enabled = state
)
Martijn

CGTalk Moderation
01-06-2009, 11:55 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.