OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: docsaintly on March 31, 2009, 12:18:17 PM

Title: List Box item data
Post by: docsaintly on March 31, 2009, 12:18:17 PM
So I've turned to the help (after searching for working examples) on how the Item data works for the List Box. I see two listings for it under help, one is under properties (as Item Data) , the other is under methods as GetItemdata. They appear to call the same function but note different arguments. After setting the list box contents with

Code (autolisp) Select
(setq strings (list "String 1" "String 2" "String 3" "String 4"))
(dcl_ListBox_AddList cover_disc_select_pickdisc strings)


and then trying

Code (autolisp) Select
(dcl_ListBox_GetItemData cover_disc_select_pickdisc 0)

it always returns 0 no matter which position I select. Any ideas?
Title: Re: List Box item data
Post by: BazzaCAD on March 31, 2009, 12:27:37 PM
Are you trying to get the selected item?
If so you'll want to use: dcl_ListBox_GetCurSel
http://www.opendcl.com/HelpFiles/ENU/Reference/Method/ListBox/GetCurSel.htm (http://www.opendcl.com/HelpFiles/ENU/Reference/Method/ListBox/GetCurSel.htm)
This will return the index on the selected item, 0,1,2, etc....
Then if you want it's text use:
dcl_ListBox_GetItemText
http://www.opendcl.com/HelpFiles/ENU/Reference/Method/ListBox/GetItemText.htm (http://www.opendcl.com/HelpFiles/ENU/Reference/Method/ListBox/GetItemText.htm)
Title: Re: List Box item data
Post by: docsaintly on March 31, 2009, 12:30:21 PM
Thanks BazzaCad, right after i posted i started digging around and noticed the GetItemText function. I assume the Data is for special data you attach to the item?
Title: Re: List Box item data
Post by: BazzaCAD on March 31, 2009, 12:46:13 PM
Ya it's for the more specific Combo Boxes like the Acad colors, I've never used it with List Boxes.
Just a tip, you can Double Click on a property in the properties panel & it will bring up help on that topic.

 
Title: Re: List Box item data
Post by: Fred Tomke on March 31, 2009, 11:05:29 PM
Hello,

I use ItemData in ListViews, Trees and Grids for adressing specified recordsets in database tables or views. Just imagine a list of groups defined in the database having the structure ID as integer | NAME as char | DESC as longchar. You put the names into the list and put the ID as ItemData using SetItemData method. Whenever the user changed the selection in the list you get the right item not by using the selected name but by getting the ItemData from the selected item. That's one of a million examples how to use ItemData in any kind of OpenDCL lists (combo, listbox, listview, tree, grid).

Fred