From: Lloyd on 11 Dec 2006 23:40 Hi, I am using the wxListCtrl in wxLC_REPORT|wxLC_VIRTUAL mode to insert the data. Is there any way for me to assign some kind of hidden data with each raw? (Which can be returned when mouse click event occur on a raw) Thanks, Lloyd ______________________________________ Scanned and protected by Email scanner --------------------------------------------------------------------- To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org
From: Andreas Micheler on 12 Dec 2006 00:47 Lloyd wrote: > Hi, > I am using the wxListCtrl in wxLC_REPORT|wxLC_VIRTUAL mode to insert > the data. Is there any way for me to assign some kind of hidden data > with each raw? (Which can be returned when mouse click event occur on a > raw) You can define an objarr array, then use it as usual in your click handler. This is like I do in aUCBLogo's StackVars window: //in the header: wxArrayString namearr, valarr; wxArrayPtrVoid objarr; // in the implementation: wxString StackVars::OnGetItemText(long item, long column) const { if (inupdate) return wxEmptyString; if (!column) return namearr[item]; return valarr[item]; } void StackVars::OnClick(wxListEvent &ev) { NodeP nd=NodeP(objarr[ev.GetIndex()]); if (!nd) return; nd->setExpanded(!nd->expanded()); update(); } Cheers, Andreas
From: Lloyd on 12 Dec 2006 01:56 Thanks Andreas. What I understood from your code is, when a mouse click event occurs it gets the index of the currently selected item and it returns the data from the Array (based on the index). But my case is different! What I actually want is - I have some column headers, and when the user clicks on the column header I want to sort the list based on that column. In this case each time the list is sorted, the index which returns will be changed for the same data in the raw! (Because the raw position shuffles). If it was not in wxLC_VIRTUAL mode I could have used wxListCtrl::SetItemData() and wxListCtrl::GetItemData() Any suggestions? Thanks, Lloyd Lloyd wrote: > Hi, > I am using the wxListCtrl in wxLC_REPORT|wxLC_VIRTUAL mode to insert > the data. Is there any way for me to assign some kind of hidden data > with each raw? (Which can be returned when mouse click event occur on a > raw) You can define an objarr array, then use it as usual in your click handler. This is like I do in aUCBLogo's StackVars window: //in the header: wxArrayString namearr, valarr; wxArrayPtrVoid objarr; // in the implementation: wxString StackVars::OnGetItemText(long item, long column) const { if (inupdate) return wxEmptyString; if (!column) return namearr[item]; return valarr[item]; } void StackVars::OnClick(wxListEvent &ev) { NodeP nd=NodeP(objarr[ev.GetIndex()]); if (!nd) return; nd->setExpanded(!nd->expanded()); update(); } Cheers, Andreas ______________________________________ Scanned and protected by Email scanner --------------------------------------------------------------------- To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org
From: Andreas Micheler on 12 Dec 2006 02:11 Lloyd wrote: > Thanks Andreas. > > What I understood from your code is, when a mouse click event occurs it > gets the index of the currently selected item and it returns the data > from the Array (based on the index). > > But my case is different! What I actually want is - > > I have some column headers, and when the user clicks on the column > header I want to sort the list based on that column. In this case each > time the list is sorted, the index which returns will be changed for the > same data in the raw! (Because the raw position shuffles). > > If it was not in wxLC_VIRTUAL mode I could have used > wxListCtrl::SetItemData() and wxListCtrl::GetItemData() > > > Any suggestions? When you sort your column, can't you just sort an array (while sorting your column), which contains the row number? You'd probably have to write some special sort function, which simultanously sorts two things, but it will work, I think. Then you can access your objarr indirectly via your row array. Cheers, Andreas
From: Vadim Zeitlin on 12 Dec 2006 04:22 On Tue, 12 Dec 2006 10:10:58 +0530 Lloyd <lloyd(a)cdactvm.in> wrote: L> I am using the wxListCtrl in wxLC_REPORT|wxLC_VIRTUAL mode to insert L> the data. Is there any way for me to assign some kind of hidden data L> with each raw? It doesn't make much sense to do this. If you use wxLC_VIRTUAL mode you already have the data shown in the control somewhere else, why don't you just add whatever "hidden" data you have to the same place? Regards, VZ -- TT-Solutions: wxWidgets consultancy and technical support http://www.tt-solutions.com/ --------------------------------------------------------------------- To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org
|
Next
|
Last
Pages: 1 2 Prev: *.Add problem Next: Yield(), WXUNUSED() and compile errors with wxMSW2.8.0rc1 |