TheSwamp

Code Red => Visual DCL Programming => AutoLISP (Vanilla / Visual) => OpenDCL => Topic started by: Guest on October 04, 2007, 09:47:17 AM

Title: Automatically Select (highlight) Listbox Item
Post by: Guest on October 04, 2007, 09:47:17 AM
I've also posted over here (http://www.opendcl.com/forum/index.php?topic=61.0), 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.
Title: Re: Automatically Select (highlight) Listbox Item
Post by: ASMI 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'?
Title: Re: Automatically Select (highlight) Listbox Item
Post by: Guest 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.
Title: Re: Automatically Select (highlight) Listbox Item
Post by: ASMI 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]))
Title: Re: Automatically Select (highlight) Listbox Item
Post by: T.Willey 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)
Title: Re: Automatically Select (highlight) Listbox Item
Post by: Guest 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.
Title: Re: Automatically Select (highlight) Listbox Item
Post by: BazzaCAD 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 (https://sourceforge.net/project/showfiles.php?group_id=187950&package_id=220267&release_id=482977)
Title: Re: Automatically Select (highlight) Listbox Item
Post by: BazzaCAD 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.
Title: Re: Automatically Select (highlight) Listbox Item
Post by: ASMI 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.
Title: Re: Automatically Select (highlight) Listbox Item
Post by: Guest 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.
Title: Re: Automatically Select (highlight) Listbox Item
Post by: T.Willey 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:
Title: Re: Automatically Select (highlight) Listbox Item
Post by: owenwengerd 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.
Title: Re: Automatically Select (highlight) Listbox Item
Post by: ASMI on October 04, 2007, 05:32:12 PM
There is short example.








Title: Re: Automatically Select (highlight) Listbox Item
Post by: ASMI on October 04, 2007, 05:33:27 PM
Yes, it is latest 4.1 Alpha 9.
Title: Re: Automatically Select (highlight) Listbox Item
Post by: Guest on October 05, 2007, 01:23:28 PM
There is short example.

Can you post it as a ZIP instead of a RAR?
Title: Re: Automatically Select (highlight) Listbox Item
Post by: Kerry 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)
)
Title: Re: Automatically Select (highlight) Listbox Item
Post by: Kerry 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
Title: Re: Automatically Select (highlight) Listbox Item
Post by: ASMI on October 08, 2007, 05:01:14 AM
Code: [Select]
Can you post it as a ZIP instead of a RAR?