Hi to all.
I have a question: how can I set an item ID to item to add and get it when selected?
I want add an object got from a database and this object has an id and a label, I want show the label and get the id when selected.
I'm very sorry for my english but I hope you can understand me
thanks a lot in advance
wxtreectrl item id and label Topic is solved
Re: wxtreectrl item id and label
Derive your own class from wxTreeItemData, in the subclass you can add member variables to store additional information. Then use wxTreeCtrl::SetItemData() to assign it to an item.
Check the "treectrl" sample that comes with wxWidgets, look for occurrences of "MyTreeItemData".
https://docs.wxwidgets.org/trunk/classw ... 11bb4b3b46
Check the "treectrl" sample that comes with wxWidgets, look for occurrences of "MyTreeItemData".
https://docs.wxwidgets.org/trunk/classw ... 11bb4b3b46
Use the source, Luke!
Re: wxtreectrl item id and label
Oh!
Thanks a lot!
Thanks a lot!
Re: wxtreectrl item id and label
for those are interested...
Code: Select all
class TreeObject : public wxTreeItemData
{
private:
wxString label;
long long id;
long long idTipo;
public:
wxString GetLabel(){ return label;}
void SetLabel(wxString label){ this->label = label;}
long long GetId(){ return id;}
void SetId(long long id){ this->id = id;}
long long GetIdTipo(){ return idTipo;}
void SetIdTipo(long long id){ this->idTipo = id;}
};
Code: Select all
void ReportSettOggettiDialog::OnClickTree(wxTreeEvent& event)
{
wxTreeItemId selezione = event.GetItem();
TreeObject* item = (TreeObject*)tree->GetItemData(selezione);
cout << item->GetIdTipo() << ", " << item->GetId() << ", "<< item->GetLabel() << endl;
}