| Version: 3.0.2

- Main Page
- Related Pages
- Categories
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | List of all members
wxTreeItemData Class Reference
Containers

`#include <wx/treebase.h>`

Inheritance diagram for wxTreeItemData:
[legend]

## Detailed Description

wxTreeItemData is some (arbitrary) user class associated with some item.

The main advantage of having this class is that wxTreeItemData objects are destroyed automatically by the tree and, as this class has virtual destructor, it means that the memory and any other resources associated with a tree item will be automatically freed when it is deleted. Note that we don't use wxObject as the base class for wxTreeItemData because the size of this class is critical: in many applications, each tree leaf will have wxTreeItemData associated with it and the number of leaves may be quite big.

Also please note that because the objects of this class are deleted by the tree using the operator `delete`, they must always be allocated on the heap using `new`.

##

Library: wxCore
Category: Containers

See Also
  wxTreeCtrl

## Public Member Functions
| wxTreeItemData ()
| Default constructor.
virtual | ~wxTreeItemData ()
| Virtual destructor.
const wxTreeItemId & | GetId () const
| Returns the item associated with this node.
void | SetId (const wxTreeItemId &id)
| Sets the item associated with this node.
Public Member Functions inherited from wxClientData
| wxClientData ()
| Constructor.
virtual | ~wxClientData ()
| Virtual destructor.

## Constructor & Destructor Documentation

wxTreeItemData::wxTreeItemData | ( |  | ) |

Default constructor.

wxPerl Note: In wxPerl the constructor accepts a scalar as an optional parameter and stores it as client data; use

- GetData() to retrieve the value.
- SetData(data) to set it.

virtual wxTreeItemData::~wxTreeItemData | ( |  | ) |
| virtual

Virtual destructor.

## Member Function Documentation

const wxTreeItemId& wxTreeItemData::GetId | ( |  | ) | const

Returns the item associated with this node.

void wxTreeItemData::SetId | ( | const wxTreeItemId & | id | ) |

Sets the item associated with this node.

Notice that this function is automatically called by wxTreeCtrl methods associating an object of this class with a tree control item such as wxTreeCtrl::AppendItem(), wxTreeCtrl::InsertItem() and wxTreeCtrl::SetItemData() so there is usually no need to call it yourself.