Started by docsaintly ·
2009-03-31 19:18 UTC ·
4 replies · SMF topic #686
docsaintly
2009-03-31 19:18 UTC
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
(setq strings (list "String 1" "String 2" "String 3" "String 4"))
(dcl_ListBox_AddList cover_disc_select_pickdisc strings)
and then trying
(dcl_ListBox_GetItemData cover_disc_select_pickdisc 0)
it always returns 0 no matter which position I select. Any ideas?
bazzacad
2009-03-31 19:27 UTC
Are you trying to get the selected item?
If so you'll want to use: dcl_ListBox_GetCurSel
{2}
This will return the index on the selected item, 0,1,2, etc....
Then if you want it's text use:
dcl_ListBox_GetItemText
{2}
docsaintly
2009-03-31 19:30 UTC
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
2009-03-31 19:46 UTC
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.
fred_tomke
2009-04-01 06:05 UTC
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