OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: scott_cd on February 10, 2017, 04:57:55 AM

Title: How to set a checkbox as checked
Post by: scott_cd on February 10, 2017, 04:57:55 AM
I am trying to set a checkbox and I am not sure of the correct syntax and I am using the following code:

Code (autolisp) Select
(dcl-Control-SetProperty Tree_Survey/Form1/CheckBox7 1)

I understand that

0 = unchecked
1 = checked
2 = indeterminate

Using control property as below what is the PropertyApiName ?

(dcl-Control-SetProperty Tree_Survey/Form1/CheckBox7 PropertyApiName [as String] NewValue [as Varies])

Thanks in advance
Scott
Title: Re: How to set a checkbox as checked
Post by: marcoheuer on February 10, 2017, 05:15:41 AM
Code (autolisp) Select
(dcl-Control-SetValue Tree_Survey/Form1/CheckBox7 1)

best regards
marco
Title: Re: How to set a checkbox as checked
Post by: scott_cd on February 10, 2017, 05:36:45 AM
(dcl-Control-SetValue Tree_Survey/Form1/CheckBox7 1)

Hi Marco

Thanks forthat.

I have as you suggested changed it to set value but I still get the following error - see attached image?

Nil value not allowed ?

Title: Re: How to set a checkbox as checked
Post by: roy_043 on February 10, 2017, 06:02:21 AM
The error message suggests that Tree_Survey/Form1/CheckBox7 control does not exist.
Title: Re: How to set a checkbox as checked
Post by: scott_cd on February 10, 2017, 06:08:38 AM
Would it help if I post my odcl file?
Title: Re: How to set a checkbox as checked
Post by: roy_043 on February 10, 2017, 06:09:29 AM
Sure.
Title: Re: How to set a checkbox as checked
Post by: scott_cd on February 10, 2017, 06:11:36 AM
my odcl file is attached.

Thanks for helping

Scott
Title: Re: How to set a checkbox as checked
Post by: roy_043 on February 10, 2017, 06:27:54 AM
Initializing the dialog must be done in an event handler called OnInitialize (to quote the Help).
Code (autolisp) Select
(defun c:Tree_Survey/Form1#OnInitialize (/)
  (dcl-Control-SetValue Tree_Survey/Form1/CheckBox7 1)
)
Title: Re: How to set a checkbox as checked
Post by: scott_cd on February 10, 2017, 06:30:16 AM
Yes that makes sense... ;D

Thanks again.