## wxTreeItemData

wxTreeItemData is some (arbitrary) user class associated with some item. The main advantage of having this class (compared to the old untyped interface) is that wxTreeItemData's are destroyed automatically by the tree and, as this class has virtual dtor, it means that the memory will be automatically freed. We don't just use wxObject instead of wxTreeItemData because the size of this class is critical: in any real application, each tree leaf will have wxTreeItemData associated with it and number of leaves may be quite big.

Because the objects of this class are deleted by the tree, they should always be allocated on the heap.

Derived from

wxTreeItemId

Include files

<wx/treectrl.h>

See also

wxTreeCtrl

Members

wxTreeItemData::wxTreeItemData
wxTreeItemData::~wxTreeItemData
wxTreeItemData::GetId
wxTreeItemData::SetId

### wxTreeItemData::wxTreeItemData

wxTreeItemData()

Default constructor.

wxPython note: The wxPython version of this constructor optionally accepts any Python object as a parameter. This object is then associated with the tree item using the wxTreeItemData as a container.

In addition, the following methods are added in wxPython for accessing the object:

GetData() | Returns a reference to the Python Object
SetData(obj) | Associates a new Python Object with the wxTreeItemData

### wxTreeItemData::~wxTreeItemData

void ~wxTreeItemData()

Virtual destructor.

### wxTreeItemData::GetId

const wxTreeItem& GetId()

Returns the item associated with this node.

### wxTreeItemData::SetId

void SetId(const wxTreeItemId& id)

Sets the item associated with this node.