List Box item data

Started by docsaintly, March 31, 2009, 12:18:17 PM

Previous topic - Next topic

docsaintly

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?

BazzaCAD

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
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
a.k.a.
Barry Ralphs
barryDOTralphsATgmailDOTcom

docsaintly

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?

BazzaCAD

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.

 
a.k.a.
Barry Ralphs
barryDOTralphsATgmailDOTcom

Fred Tomke

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
Fred Tomke
Dipl.-Ing. (FH) Landespflege

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