wxComboBox Class Reference
[Controls]

#include <wx/combobox.h>

Inheritance diagram for wxComboBox:
Inheritance graph
[legend]

Detailed Description

A combobox is like a combination of an edit control and a listbox.

It can be displayed as static list with editable or read-only text field; or a drop-down list with text field; or a drop-down list without a text field.

A combobox permits a single selection only. Combobox items are numbered from zero.

If you need a customized combobox, have a look at wxComboCtrl, wxOwnerDrawnComboBox, wxComboPopup and the ready-to-use wxBitmapComboBox.

Please refer to wxTextEntry documentation for the description of methods operating with the text entry part of the combobox.

Styles

This class supports the following styles:

Events emitted by this class

The following event handler macros redirect the events to member function handlers 'func' with prototypes like:

void handlerFuncName(wxCommandEvent& event)

Event macros for events emitted by this class:

Library:  wxCore
Category:  Controls

Appearance:
wxMSW appearancewxGTK appearancewxMac appearance
wxMSW appearancewxGTK appearancewxMac appearance
See also:
wxListBox, wxTextCtrl, wxChoice, wxCommandEvent

Public Member Functions

 wxComboBox ()
 Default constructor.
 wxComboBox (wxWindow *parent, wxWindowID id, const wxString &value=wxEmptyString, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, int n=0, const wxString choices[]=NULL, long style=0, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxComboBoxNameStr)
 Constructor, creating and showing a combobox.
 wxComboBox (wxWindow *parent, wxWindowID id, const wxString &value, const wxPoint &pos, const wxSize &size, const wxArrayString &choices, long style=0, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxComboBoxNameStr)
 Constructor, creating and showing a combobox.
virtual ~wxComboBox ()
 Destructor, destroying the combobox.
virtual int GetCurrentSelection () const
 Returns the item being selected right now.
virtual long GetInsertionPoint () const
 Same as wxTextEntry::GetInsertionPoint().
virtual void SetSelection (long from, long to)
 Same as wxTextEntry::SetSelection().
virtual void SetValue (const wxString &text)
 Sets the text for the combobox text field.



bool Create (wxWindow *parent, wxWindowID id, const wxString &value=wxEmptyString, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, int n=0, const wxString choices[]=(const wxString *) NULL, long style=0, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxComboBoxNameStr)
 Creates the combobox for two-step construction.
bool Create (wxWindow *parent, wxWindowID id, const wxString &value, const wxPoint &pos, const wxSize &size, const wxArrayString &choices, long style=0, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxComboBoxNameStr)
 Creates the combobox for two-step construction.

List of all members.


Constructor & Destructor Documentation

wxComboBox::wxComboBox (  ) 

Default constructor.

wxComboBox::wxComboBox ( wxWindow parent,
wxWindowID  id,
const wxString value = wxEmptyString,
const wxPoint pos = wxDefaultPosition,
const wxSize size = wxDefaultSize,
int  n = 0,
const wxString  choices[] = NULL,
long  style = 0,
const wxValidator validator = wxDefaultValidator,
const wxString name = wxComboBoxNameStr 
)

Constructor, creating and showing a combobox.

Parameters:
parent Parent window. Must not be NULL.
id Window identifier. The value wxID_ANY indicates a default value.
value Initial selection string. An empty string indicates no selection. Notice that for the controls with wxCB_READONLY style this string must be one of the valid choices if it is not empty.
pos Window position. If wxDefaultPosition is specified then a default position is chosen.
size Window size. If wxDefaultSize is specified then the window is sized appropriately.
n Number of strings with which to initialise the control.
choices An array of strings with which to initialise the control.
style Window style. See wxComboBox.
validator Window validator.
name Window name.

wxPython Note: The wxComboBox constructor in wxPython reduces the n and choices arguments are to a single argument, which is a list of strings.

wxPerl Note: Not supported by wxPerl.

See also:
Create(), wxValidator
wxComboBox::wxComboBox ( wxWindow parent,
wxWindowID  id,
const wxString value,
const wxPoint pos,
const wxSize size,
const wxArrayString choices,
long  style = 0,
const wxValidator validator = wxDefaultValidator,
const wxString name = wxComboBoxNameStr 
)

Constructor, creating and showing a combobox.

Parameters:
parent Parent window. Must not be NULL.
id Window identifier. The value wxID_ANY indicates a default value.
value Initial selection string. An empty string indicates no selection.
pos Window position.
size Window size. If wxDefaultSize is specified then the window is sized appropriately.
choices An array of strings with which to initialise the control.
style Window style. See wxComboBox.
validator Window validator.
name Window name.

wxPython Note: The wxComboBox constructor in wxPython reduces the n and choices arguments are to a single argument, which is a list of strings.

wxPerl Note: Use an array reference for the choices parameter.

See also:
Create(), wxValidator
virtual wxComboBox::~wxComboBox (  )  [virtual]

Destructor, destroying the combobox.


Member Function Documentation

bool wxComboBox::Create ( wxWindow parent,
wxWindowID  id,
const wxString value,
const wxPoint pos,
const wxSize size,
const wxArrayString choices,
long  style = 0,
const wxValidator validator = wxDefaultValidator,
const wxString name = wxComboBoxNameStr 
)

Creates the combobox for two-step construction.

Derived classes should call or replace this function. See wxComboBox() for further details.

Reimplemented in wxBitmapComboBox.

bool wxComboBox::Create ( wxWindow parent,
wxWindowID  id,
const wxString value = wxEmptyString,
const wxPoint pos = wxDefaultPosition,
const wxSize size = wxDefaultSize,
int  n = 0,
const wxString  choices[] = (const wxString *) NULL,
long  style = 0,
const wxValidator validator = wxDefaultValidator,
const wxString name = wxComboBoxNameStr 
)

Creates the combobox for two-step construction.

Derived classes should call or replace this function. See wxComboBox() for further details.

Reimplemented in wxBitmapComboBox.

virtual int wxComboBox::GetCurrentSelection (  )  const [virtual]

Returns the item being selected right now.

This function does the same things as wxChoice::GetCurrentSelection() and returns the item currently selected in the dropdown list if it's open or the same thing as wxControlWithItems::GetSelection() otherwise.

virtual long wxComboBox::GetInsertionPoint (  )  const [virtual]

Same as wxTextEntry::GetInsertionPoint().

Note:
Under wxMSW, this function always returns 0 if the combobox doesn't have the focus.

Reimplemented from wxTextEntry.

virtual void wxComboBox::SetSelection ( long  from,
long  to 
) [virtual]

Same as wxTextEntry::SetSelection().

wxPython Note: This method is called SetMark() in wxPython, "SetSelection" is kept for wxControlWithItems::SetSelection().

Reimplemented from wxTextEntry.

virtual void wxComboBox::SetValue ( const wxString text  )  [virtual]

Sets the text for the combobox text field.

Notice that this method will generate a wxEVT_COMMAND_TEXT_UPDATED event, use wxTextEntry::ChangeValue() if this is undesirable.

Note:
For a combobox with wxCB_READONLY style the string must be in the combobox choices list, otherwise the call to SetValue() is ignored.
Parameters:
text The text to set.

Reimplemented from wxTextEntry.

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines



wxWidgets logo

[ top ]