Topic: Conditional Enable Disable

Hi Guys,


I'm trying conditionally enable / disable a combobox depending on which checkbox checked or not checked.
I used two checkboxes as a radio buttons (Thanks to Mathias). Radio buttons part works fine but not enable disable.
Combobox should be enabled only when one of the specific checkbox checked. All other instances it should be disabled.


I have tried Derek's method of showing/hiding groupbox/panel but encountered some issues, most likely my incorrect implementation. In any case, I'd like to do it with checkboxes using enable disable method.


Please see the attached sample project.

Post's attachments

Attachment icon Conditional Enable Disable.zip 6.14 kb, 374 downloads since 2016-12-05 

Adam
God... please help me become the person my dog thinks I am.

2 (edited by derek 2016-12-05 23:58:29)

Re: Conditional Enable Disable

Hello Adam,
I use showing/hiding groupbox/panel simply because you only need to issue one set of instructions that then includes all the objects contained within the groupbox or panel.  But the principle is exactly the same for individual edit fields etc etc.
Attached is your example working as I believe you want it to (and with the script changes commented - I'm sure Mathias thinks I never comment my code - LOL!!  Only joking). 
(If you want to use enable/disable rather than visible/invisible, simple change the script from .visible to .enabled and change the default settings on the object properties on Form1 from visible = false to enabled = false).
Derek.

Post's attachments

Attachment icon Conditional Enable Disable.zip 338.71 kb, 363 downloads since 2016-12-06 

Re: Conditional Enable Disable

Hi Derek,


Thanks a lot for your kind help...


I have added clear fields after save, where 1 form used. Hopefully it's correct, it seems to be working fine.


Now, let see if anybody can do it by disabling combobox rather than hiding...


The attached sample project includes clear fields, otherwise same as Derek's version.

Post's attachments

Attachment icon Conditional Enable Disable 1.1.zip 7.68 kb, 370 downloads since 2016-12-06 

Adam
God... please help me become the person my dog thinks I am.

Re: Conditional Enable Disable

Hello Adam,
As I said in my last post, you can just replace the .visible with .enabled in the relevant lines in the script and change the object properties on the form.  Anyway, it's in the attachment.
I was confused by form1.tgprod and form1.tablegrid1 - they both show product data so wasn't sure why you have both on the form.
If you're serious about using just one form, I'd strongly advise at least the following:
1.  setting your fields to mandatory, where possible. 
2.  conditionally hide the 'save' button unless either the 'own product' or the 'purchased product' checkbox is ticked.
I say this because it is far too easy just to accidently click 'save' and create empty records (or, once you've added an 'edit' button), to create duplicates of existing records as well.  Try clicking 'save' a few times and see what happens. 
Just my opinion, for what it's worth.
Derek.

Post's attachments

Attachment icon Conditional Enable Disable 1.zip 339.56 kb, 421 downloads since 2016-12-06 

Re: Conditional Enable Disable

Hi Derek,


It seems I've failed to give proper attention to your last para on your previous post. My bad.
Thank you very much for your latest post.

Adam
God... please help me become the person my dog thinks I am.