dcl_ComboBox_SetCurSel with current value

Started by Peter2, November 16, 2014, 11:47:50 PM

Previous topic - Next topic

Peter2

I'm sure there is an existing, obvious function in OpenDCL, but at the moment I'm blind to see it ...

- I have a ComboBox with some entries: (list "Jim" "John "Sue "Anne")
- Somewhere in Lisp there is: (setq myvalue "Sue")

-> How to use "dcl_ComboBox_SetCurSel" with "Sue"?

I use "vl-position", but I'm sure there is a better way:
Code (autolisp) Select
(dcl_ComboBox_SetCurSel haupt_cbxModus (vl-position selMode (dcl_Control_GetList haupt_cbxModus)))

Have a  fine week!
Peter
ODCL 8.1.... German, AutoCAD 2017 - 2018, Win 7 x64, Win 10

owenwengerd

The normal pattern is to either call (dcl-ComboBox-SelectString) to select the first item with matching prefix, or else (dcl-ComboBox-FindStringExact) plus (dcl-ComboBox-SetCurSel) if you need to ensure an exact match.
Owen Wengerd (Outside The Box) / ManuSoft

Peter2

Peter
ODCL 8.1.... German, AutoCAD 2017 - 2018, Win 7 x64, Win 10

Peter2

Quote from: Peter2 on November 16, 2014, 11:47:50 PM
I'm sure there is an existing, obvious function in OpenDCL, but at the moment I'm blind to see it ...

- I have a ComboBox with some entries: (list "Jim" "John "Sue "Anne")
- Somewhere in Lisp there is: (setq myvalue "Sue")

-> How to use "dcl_ComboBox_SetCurSel" with "Sue"?

I use "vl-position", but I'm sure there is a better way:
Code (autolisp) Select
(dcl_ComboBox_SetCurSel haupt_cbxModus (vl-position selMode (dcl_Control_GetList haupt_cbxModus)))

Have a  fine week!
Peter
ODCL 8.1.... German, AutoCAD 2017 - 2018, Win 7 x64, Win 10