Author Topic: Automatically Select (highlight) Listbox Item  (Read 15237 times)

0 Members and 1 Guest are viewing this topic.

Guest

  • Guest
Automatically Select (highlight) Listbox Item
« on: October 04, 2007, 09:47:17 AM »
I've also posted over here, but thought I'd ask here as well since this site gets more attention.

So here goes...

How can I automatically select a listbox item and highlight it?  I only know the text of the item, not it's number (location) in the list.

Thanks.

ASMI

  • Guest
Re: Automatically Select (highlight) Listbox Item
« Reply #1 on: October 04, 2007, 10:16:38 AM »
Quote
Method SetSel

This method will set the indicated list item in a multiple selection ListBox as selected or unselected. 
 
AutoLISP Syntax:
(dcl_ListBox_SetSel Text_Numbering_V1_0_Form1_ListBox23
   nIndex [as Integer]
   nIsSelected [as Integer: 0 = Not Selected, 1 = Selected])

I don't undersand because there is three forums 'VisualDCL Programming', 'OpenDCL' and 'ObjectDCL'? What for 'VisualDCL Programming'?

Guest

  • Guest
Re: Automatically Select (highlight) Listbox Item
« Reply #2 on: October 04, 2007, 10:26:16 AM »
Quote
Method SetSel

This method will set the indicated list item in a multiple selection ListBox as selected or unselected. 
 
AutoLISP Syntax:
(dcl_ListBox_SetSel Text_Numbering_V1_0_Form1_ListBox23
   nIndex [as Integer]
   nIsSelected [as Integer: 0 = Not Selected, 1 = Selected])

I don't undersand because there is three forums 'VisualDCL Programming', 'OpenDCL' and 'ObjectDCL'? What for 'VisualDCL Programming'?


Thanks but I don't know what number the text is in the list so the Integer piece is useless to me right now until I can determine where in the list the text resides - unless I'm missing something.

ASMI

  • Guest
Re: Automatically Select (highlight) Listbox Item
« Reply #3 on: October 04, 2007, 10:45:01 AM »
To find Index of text string use FindStringExact method, then select it with SetSel method.

Quote
Method FindStringExact as Integer

This method finds the first string in a ListBox that contains a list item with the exact string match without changing the ListBox selection. A search for "Example Text" will find "Example Text". Use the dcl_ListBox_SelectString function instead to both find and select a string.
 
AutoLISP Syntax:
(Setq rValue (dcl_ListBox_FindStringExact Text_Numbering_V1_0_Form1_ListBox23
   SearchString [as String]))

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Automatically Select (highlight) Listbox Item
« Reply #4 on: October 04, 2007, 11:15:19 AM »
To find Index of text string use FindStringExact method, then select it with SetSel method.

Quote
Method FindStringExact as Integer

This method finds the first string in a ListBox that contains a list item with the exact string match without changing the ListBox selection. A search for "Example Text" will find "Example Text". Use the dcl_ListBox_SelectString function instead to both find and select a string.
 
AutoLISP Syntax:
(Setq rValue (dcl_ListBox_FindStringExact Text_Numbering_V1_0_Form1_ListBox23
   SearchString [as String]))
or use dcl_ListBox_SelectString (see bolded and enlarge sized line in quote above, by me)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Guest

  • Guest
Re: Automatically Select (highlight) Listbox Item
« Reply #5 on: October 04, 2007, 11:26:14 AM »
To find Index of text string use FindStringExact method, then select it with SetSel method.

Quote
Method FindStringExact as Integer

This method finds the first string in a ListBox that contains a list item with the exact string match without changing the ListBox selection. A search for "Example Text" will find "Example Text". Use the dcl_ListBox_SelectString function instead to both find and select a string.
 
AutoLISP Syntax:
(Setq rValue (dcl_ListBox_FindStringExact Text_Numbering_V1_0_Form1_ListBox23
   SearchString [as String]))
or use dcl_ListBox_SelectString (see bolded and enlarge sized line in quote above, by me)

'snot working, man!  What version are you running?  I've got 4.0.2.4.

BazzaCAD

  • Guest
Re: Automatically Select (highlight) Listbox Item
« Reply #6 on: October 04, 2007, 12:35:00 PM »
'snot working, man!  What version are you running?  I've got 4.0.2.4.

Wow you're way out of date dude.
The current stable version is 4.0.3.1 & the experimental 4.1 alpha version is 4.1.0.9.
You should at least update to 4.0.3.1 https://sourceforge.net/project/showfiles.php?group_id=187950&package_id=220267&release_id=482977

BazzaCAD

  • Guest
Re: Automatically Select (highlight) Listbox Item
« Reply #7 on: October 04, 2007, 12:40:26 PM »
I don't undersand because there is three forums 'VisualDCL Programming', 'OpenDCL' and 'ObjectDCL'? What for 'VisualDCL Programming'?

This post should actually be in the "OpenDCL" forum, since thats what is seams you're asking about...
"ObjectDCL" is anther product.
"VisualDCL Programming" is for stuff like using VBA forms with Lisp or just basic DCL forms.

ASMI

  • Guest
Re: Automatically Select (highlight) Listbox Item
« Reply #8 on: October 04, 2007, 01:38:17 PM »
> Matt W
Quote
'snot working, man!

Do you really think that?

>BazzaCAD
Quote
"ObjectDCL" is anther product.

I know it, because pay for it 300$ aproximetely 3 years ago. But this product (in that time) had too many bags with Atocad crach :( I have some programs on it (for my own and my friends usage), but can't offer it to other people.

Quote
"VisualDCL Programming" is for stuff like using VBA forms with Lisp or just basic DCL forms.

Now it's clear for me.

Guest

  • Guest
Re: Automatically Select (highlight) Listbox Item
« Reply #9 on: October 04, 2007, 01:40:28 PM »
> Matt W
Quote
'snot working, man!

Do you really think that?

Can you post a short, working example because what I've got isn't working.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Automatically Select (highlight) Listbox Item
« Reply #10 on: October 04, 2007, 02:32:40 PM »
I just peeked in here, and saw what was posted, and you question.  I don't use OpenDcl .... so I'm no much help in this forum.  :roll:
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

owenwengerd

  • Bull Frog
  • Posts: 451
Re: Automatically Select (highlight) Listbox Item
« Reply #11 on: October 04, 2007, 05:30:23 PM »
Matt, try installing the latest version of OpenDCL and let us know whether you still have the problem.

ASMI

  • Guest
Re: Automatically Select (highlight) Listbox Item
« Reply #12 on: October 04, 2007, 05:32:12 PM »
There is short example.









ASMI

  • Guest
Re: Automatically Select (highlight) Listbox Item
« Reply #13 on: October 04, 2007, 05:33:27 PM »
Yes, it is latest 4.1 Alpha 9.

Guest

  • Guest
Re: Automatically Select (highlight) Listbox Item
« Reply #14 on: October 05, 2007, 01:23:28 PM »
There is short example.

Can you post it as a ZIP instead of a RAR?

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Automatically Select (highlight) Listbox Item
« Reply #15 on: October 05, 2007, 06:59:29 PM »
There is short example.

Can you post it as a ZIP instead of a RAR?

Matt,
here's the essential code ASMI posted ..
Code: [Select]
;;
;; For the example, assume the ARX is loaded
;;


(defun c:swtest ()
  (if (not (dcl_project_load "SWTest" t))
    (progn (alert (strcat "SWTest ERROR!" "Can't load file: SWTest.odcl"))
           (quit)
    )
    (progn (dcl_form_show SWTest_Form1))
  )
  (princ)
)


(defun c:SWTest_Form1_TextButton4_OnClicked (/ rValue)
  (if (/= -1
          (setq rValue (dcl_listbox_findstringexact
                         SWTest_Form1_ListBox1
                         (dcl_control_gettext SWTest_Form1_TextBox2)
                       )
          )
      )
    (dcl_listbox_setcursel SWTest_Form1_ListBox1 rValue)
    (alert "There isn't that string!")
  )
  (princ)
)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Automatically Select (highlight) Listbox Item
« Reply #16 on: October 05, 2007, 07:04:13 PM »

.. this of course finds the FULL exact string if it exists,
use (dcl_ListBox_FindString ... if you are looking for a match with partial data .. but that will also require a 'Next Match' option be coded.

/// kwb
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

ASMI

  • Guest
Re: Automatically Select (highlight) Listbox Item
« Reply #17 on: October 08, 2007, 05:01:14 AM »
Code: [Select]
Can you post it as a ZIP instead of a RAR?