wxComboBox Class Reference
[Controls]

#include <wx/combobox.h>

Inheritance diagram for wxComboBox:

wxControl wxItemContainer wxWindow wxItemContainerImmutable wxEvtHandler wxObject wxBitmapComboBox

List of all members.


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.

Styles:

Events:

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

void handlerFuncName(wxCommandEvent& event)

Event macros:
Library:  wxCore

Category:  Controls

See also:
wxListBox, wxTextCtrl, wxChoice, wxCommandEvent

Public Member Functions

 wxComboBox ()
 ~wxComboBox ()
bool CanCopy () const
bool CanCut () const
bool CanPaste () const
bool CanRedo () const
bool CanUndo () const
void Copy ()
void Cut ()
int GetCurrentSelection () const
long GetInsertionPoint () const
virtual wxTextPos GetLastPosition () const
void GetSelection (long *from, long *to) const
wxString GetValue () const
void Paste ()
void Redo ()
void Remove (long from, long to)
void Replace (long from, long to, const wxString &text)
void SetInsertionPoint (long pos)
void SetInsertionPointEnd ()
void SetSelection (long from, long to)
void SetValue (const wxString &text)
void Undo ()
 wxComboBox (wxWindow *parent, wxWindowID id, const wxString &value="", 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="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="comboBox")
bool Create (wxWindow *parent, wxWindowID id, const wxString &value="", const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, int n, const wxString choices[], long style=0, const wxValidator &validator=wxDefaultValidator, const wxString &name="comboBox")
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="comboBox")

Constructor & Destructor Documentation

wxComboBox::wxComboBox (  ) 

Default constructor.

wxComboBox::wxComboBox ( wxWindow parent,
wxWindowID  id,
const wxString value = "",
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 = "comboBox" 
)

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.
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.

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 = "comboBox" 
)

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.
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.

See also:
Create(), wxValidator

wxComboBox::~wxComboBox (  ) 

Destructor, destroying the combobox.


Member Function Documentation

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

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,
const wxPoint pos,
const wxSize size,
const wxArrayString choices,
long  style = 0,
const wxValidator validator = wxDefaultValidator,
const wxString name = "comboBox" 
)

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::CanCopy (  )  const

Returns true if the combobox is editable and there is a text selection to copy to the clipboard. Only available on Windows.

bool wxComboBox::CanCut (  )  const

Returns true if the combobox is editable and there is a text selection to copy to the clipboard. Only available on Windows.

bool wxComboBox::CanPaste (  )  const

Returns true if the combobox is editable and there is text on the clipboard that can be pasted into the text field. Only available on Windows.

bool wxComboBox::CanRedo (  )  const

Returns true if the combobox is editable and the last undo can be redone. Only available on Windows.

bool wxComboBox::CanUndo (  )  const

Returns true if the combobox is editable and the last edit can be undone. Only available on Windows.

void wxComboBox::Copy (  ) 

Copies the selected text to the clipboard.

void wxComboBox::Cut (  ) 

Copies the selected text to the clipboard and removes the selection.

int wxComboBox::GetCurrentSelection (  )  const

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.

long wxComboBox::GetInsertionPoint (  )  const

Returns the insertion point for the combobox's text field.

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

virtual wxTextPos wxComboBox::GetLastPosition (  )  const [virtual]

Returns the last position in the combobox text field.

void wxComboBox::GetSelection ( long *  from,
long *  to 
) const

This is the same as wxTextCtrl::GetSelection() for the text control which is part of the combobox. Notice that this is a different method from wxControlWithItems::GetSelection().

Currently this method is only implemented in wxMSW and wxGTK.

wxString wxComboBox::GetValue (  )  const

Returns the current value in the combobox text field.

void wxComboBox::Paste (  ) 

Pastes text from the clipboard to the text field.

void wxComboBox::Redo (  ) 

Redoes the last undo in the text field. Windows only.

void wxComboBox::Remove ( long  from,
long  to 
)

Removes the text between the two positions in the combobox text field.

Parameters:
from The first position.
to The last position.

void wxComboBox::Replace ( long  from,
long  to,
const wxString text 
)

Replaces the text between two positions with the given text, in the combobox text field.

Parameters:
from The first position.
to The second position.
text The text to insert.

void wxComboBox::SetInsertionPoint ( long  pos  ) 

Sets the insertion point in the combobox text field.

Parameters:
pos The new insertion point.

void wxComboBox::SetInsertionPointEnd (  ) 

Sets the insertion point at the end of the combobox text field.

void wxComboBox::SetSelection ( long  from,
long  to 
)

Selects the text between the two positions, in the combobox text field.

Parameters:
from The first position.
to The second position.
wxPython Note: This method is called SetMark() in wxPython, "SetSelection" is kept for wxControlWithItems::SetSelection().

void wxComboBox::SetValue ( const wxString text  ) 

Sets the text for the combobox text field.

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.

void wxComboBox::Undo (  ) 

Undoes the last edit in the text field. Windows only.



wxWidgets logo

[ top ]