Author Topic: SetCurSel based off another Listbox  (Read 436 times)

dsm_dude

  • Member
  • *
  • Posts: 11
SetCurSel based off another Listbox
« on: August 23, 2022, 01:57:23 PM »
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.
Code: [Select]
(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
  )

Fred Tomke

  • OpenDCL Technician
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2080
  • [ Mr. Bad Guy ]
    • Kommunale Entwicklungsplanung auf digitaler Basis - digital landscape and urban design
Re: SetCurSel based off another Listbox
« Reply #1 on: August 23, 2022, 04:18:17 PM »
Hi, does this the trick?

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

Regards, Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

dsm_dude

  • Member
  • *
  • Posts: 11
Re: SetCurSel based off another Listbox
« Reply #2 on: October 31, 2022, 01:51:44 PM »
Fred,

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

Thank you!!