## wxTabCtrl

This class represents a tab control, which manages multiple tabs.

Derived from

wxControl
wxWindow
wxEvtHandler
wxObject

Include files

<wx/tabctrl.h>

See also

wxTabEvent, wxImageList, wxNotebook

Members

wxTabCtrl::wxTabCtrl
wxTabCtrl::~wxTabCtrl
wxTabCtrl::Create
wxTabCtrl::DeleteAllItems
wxTabCtrl::DeleteItem
wxTabCtrl::GetCurFocus
wxTabCtrl::GetImageList
wxTabCtrl::GetItemCount
wxTabCtrl::GetItemData
wxTabCtrl::GetItemImage
wxTabCtrl::GetItemRect
wxTabCtrl::GetItemText
wxTabCtrl::GetRowCount
wxTabCtrl::GetSelection
wxTabCtrl::HitTest
wxTabCtrl::InsertItem
wxTabCtrl::SetItemData
wxTabCtrl::SetItemImage
wxTabCtrl::SetImageList
wxTabCtrl::SetItemSize
wxTabCtrl::SetItemText
wxTabCtrl::SetPadding
wxTabCtrl::SetSelection

### wxTabCtrl::wxTabCtrl

wxTabCtrl()

Default constructor.

wxTabCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size, long style = 0, const wxString& name = "tabCtrl")

Constructs a tab control.

Parameters

parent

The parent window. Must be non-NULL.

id

The window identifier.

pos

The window position.

size

The window size.

style

The window style. Its value is a bit list of zero or more of wxTC_MULTILINE, wxTC_RIGHTJUSTIFY, wxTC_FIXEDWIDTH and wxTC_OWNERDRAW.

### wxTabCtrl::~wxTabCtrl

~wxTabCtrl()

Destroys the wxTabCtrl object.

### wxTabCtrl::Create

bool Create(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size, long style = 0, const wxString& name = "tabCtrl")

Creates a tab control. See wxTabCtrl::wxTabCtrl for a description of the parameters.

### wxTabCtrl::DeleteAllItems

bool DeleteAllItems()

Deletes all tab items.

### wxTabCtrl::DeleteItem

bool DeleteItem(int item)

Deletes the specified tab item.

### wxTabCtrl::GetCurFocus

int GetCurFocus() const

Returns the index for the tab with the focus, or -1 if none has the focus.

### wxTabCtrl::GetImageList

wxImageList* GetImageList() const

Returns the associated image list.

See also

wxImageList, wxTabCtrl::SetImageList

### wxTabCtrl::GetItemCount

int GetItemCount() const

Returns the number of tabs in the tab control.

### wxTabCtrl::GetItemData

void* GetItemData() const

Returns the client data for the given tab.

### wxTabCtrl::GetItemImage

int GetItemImage() const

Returns the image index for the given tab.

### wxTabCtrl::GetItemRect

bool GetItemRect(int item, wxRect& rect) const

Returns the rectangle bounding the given tab.

See also

wxRect

### wxTabCtrl::GetItemText

wxString GetItemText() const

Returns the string for the given tab.

### wxTabCtrl::GetRowCount

int GetRowCount() const

Returns the number of rows in the tab control.

### wxTabCtrl::GetSelection

int GetSelection() const

Returns the index for the currently selected tab.

See also

wxTabCtrl::SetSelection

### wxTabCtrl::HitTest

int HitTest(const wxPoint& pt, long& flags)

Tests whether a tab is at the specified position.

Parameters

pt

Specifies the point for the hit test.

flags

Return value for detailed information. One of the following values:

wxTAB_HITTEST_NOWHERE | There was no tab under this point.
wxTAB_HITTEST_ONICON | The point was over an icon.
wxTAB_HITTEST_ONLABEL | The point was over a label.
wxTAB_HITTEST_ONITEM | The point was over an item, but not on the label or icon.

Return value

Returns the zero-based tab index or -1 if no tab is at the specified position.

### wxTabCtrl::InsertItem

void InsertItem(int item, const wxString& text, int imageId = -1, void* clientData = NULL)

Inserts a new tab.

Parameters

item

Specifies the index for the new item.

text

Specifies the text for the new item.

imageId

Specifies the optional image index for the new item.

clientData

Specifies the optional client data for the new item.

Return value

TRUE if successful, FALSE otherwise.

### wxTabCtrl::SetItemData

bool SetItemData(int item, void* data)

Sets the client data for a tab.

### wxTabCtrl::SetItemImage

bool SetItemImage(int item, int image)

Sets the image index for the given tab. image is an index into the image list which was set with wxTabCtrl::SetImageList.

### wxTabCtrl::SetImageList

void SetImageList(wxImageList* imageList)

Sets the image list for the tab control.

See also

wxImageList

### wxTabCtrl::SetItemSize

void SetItemSize(const wxSize& size)

Sets the width and height of the tabs.

### wxTabCtrl::SetItemText

bool SetItemText(int item, const wxString& text)

Sets the text for the given tab.

### wxTabCtrl::SetPadding

void SetPadding(const wxSize& padding)

Sets the amount of space around each tab's icon and label.

### wxTabCtrl::SetSelection

int SetSelection(int item)

Sets the selection for the given tab, returning the index of the previously selected tab. Returns -1 if the call was unsuccessful.

See also

wxTabCtrl::GetSelection