From: Mattia B. <mb...@ds...> - 2002-04-21 20:46:14
|
You forgot platform & wxPerl version, so I won't give you the solution ;-p > I have got a wxPerl application that contains a Wx::TreeCtrl and a > Wx::ListCtrl. Whenever a Wx::TreeCtrl item is activated, new items > are inserted in the list control. The "items" are stored as > data in the tree control. > > I am attempting to supply a hashref as data for each item in the > list control. So, in my EVT_TREE_SEL_CHANGED callback function > I have the following code: <snip> > Adding the actual *items* works fine (they display properly in the list). > The only problem is that setting the item data simply *does not work*. > Bizarrely, whenever I print out $id in the above function, it is > *always* zero. > > Anyway in my EVT_LIST_ITEM_ACTIVATED callback function I have: > > my $file_details = $object->{list}->GetItemData($event->GetItem()); > > but this causes a message box to appear saying: > > "Cannot retrieve information for list control item XXXXXXXX" (i.e. it > includes the item number). I see; this: the problem is that GetItemData takes the index of the item $list->GetItemData( $ebent->GetIndex() ), or $event->GetData() works fine > I think the problem is that there is no SetPlData etc. for listctrl like > there is for treectrl. The C++ documentation seems to show that > a listctrl item can only have a 'long' associated with it. Yes, you can use the long as an index in an array ( or in an hash ) containing the hashrefs, though. > How can I associate a hashref with each item in a listctrl and how I > can access this hashref when the item is "activated"? See above HTH Mattia |