Associating data with wxListCtrl in virtual mode

Andreas Micheler Andreas.Micheler at Student.Uni-Augsburg.de
Mon Dec 11 21:47:48 PST 2006


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






More information about the wx-users mailing list