SetCurSel based off another Listbox

Started by dsm_dude · 2022-08-23 20:57 UTC · 2 replies · SMF topic #2828

I have two list boxes in my dialog box.

One contains a description and the other a VBScript.

When I select the desired description it automatically selects the VBScript.

This is how I'm accomplishing it, but I would like to know if there is a better and more streamlined way to accomplish this.
(defun c:LabelContent/Form1/ListBox2#OnSelChanged (ItemIndexOrCount Value /)
  (setq Usel (dcl-ListBox-GetCurSel LabelContent/Form1/ListBox2))
  (cond
    ((= Usel 0)(dcl-ListBox-SetCurSel LabelContent/Form1/ListBox1 0))
    ((= Usel 1)(dcl-ListBox-SetCurSel LabelContent/Form1/ListBox1 1))
    ((= Usel 2)(dcl-ListBox-SetCurSel LabelContent/Form1/ListBox1 2))
    ((= Usel 3)(dcl-ListBox-SetCurSel LabelContent/Form1/ListBox1 3))
    ((= Usel 4)(dcl-ListBox-SetCurSel LabelContent/Form1/ListBox1 4))
    ((= Usel 5)(dcl-ListBox-SetCurSel LabelContent/Form1/ListBox1 5))
    ((= Usel 6)(dcl-ListBox-SetCurSel LabelContent/Form1/ListBox1 6))
    ((= Usel 7)(dcl-ListBox-SetCurSel LabelContent/Form1/ListBox1 7))
    ((= Usel 8)(dcl-ListBox-SetCurSel LabelContent/Form1/ListBox1 8))
    ((= Usel 9)(dcl-ListBox-SetCurSel LabelContent/Form1/ListBox1 9))
    ((= Usel 10)(dcl-ListBox-SetCurSel LabelContent/Form1/ListBox1 10))
);cond
  )
Hi, does this the trick?


(defun c:LabelContent/Form1/ListBox2#OnSelChanged (ItemIndexOrCount Value /)
  (dcl-ListBox-SetCurSel LabelContent/Form1/ListBox1 ItemIndexOrCount)
)


Regards, Fred
Fred,

You are the man. I knew there was a better way!!

Thank you!!