\membersection{wxControlWithItems::SetStringSelection}\label{wxcontrolwithitemssetstringselection}
-\func{void}{SetStringSelection}{\param{const wxString\& }{ string}}
+\func{bool}{SetStringSelection}{\param{const wxString\& }{ string}}
Selects the item with the specified string in the control. This doesn't cause
any command events being emitted.
\docparam{string}{The string to select.}
+\wxheading{Return value}
+
+\true if the specified string has been selected, \false if it wasn't found in
+the control.
+
\wxheading{See also}
\helpref{SetSelection}{wxcontrolwithitemssetselection}
// single selection logic
virtual void SetSelection(int n) = 0;
- virtual bool SetStringSelection(const wxString& s);
// don't override this
virtual void Select(int n) { SetSelection(n); }
virtual void SetSelection(int);
// Overlapping methods
virtual wxString GetStringSelection();
- // other methods
- virtual void SetStringSelection(const wxString& selection);
// wxItemContainer
virtual void Clear();
virtual void Delete(int);
// only for rtti needs (separate name)
void AppendString( const wxString& item)
- { Append( item ) ; }
+ { Append( item ); }
// append several items at once to the control
void Append(const wxArrayString& strings);
virtual void Select(int n) = 0;
virtual int GetSelection() const = 0;
+ // set selection to the specified string, return false if not found
+ bool SetStringSelection(const wxString& s);
+
+ // return the selected string or empty string if none
wxString GetStringSelection() const;
// misc
int Number() const { return GetCount(); }
void SetSelection( int n );
void Select( int n ) { return SetSelection( n ); }
- bool SetStringSelection( const wxString &string );
void SetString(int n, const wxString &text);
wxString GetValue() const;
int Number() const { return GetCount(); }
void SetSelection( int n );
void Select( int n ) { return SetSelection( n ); }
- bool SetStringSelection( const wxString &string );
void SetString(int n, const wxString &text);
wxString GetValue() const;
virtual wxString GetString(int n) const ;
virtual wxString GetStringSelection() const ;
virtual void SetString(int n, const wxString& s) ;
- virtual bool SetStringSelection(const wxString& sel);
// Text field functions
virtual wxString GetValue() const ;
virtual wxString GetString(int n) const ;
virtual wxString GetStringSelection() const ;
virtual void SetString(int n, const wxString& s) ;
- virtual bool SetStringSelection(const wxString& sel);
// Text field functions
virtual wxString GetValue() const ;
virtual int GetSelection() const;
void SetSelection(int n) { Select(n); }
- void SetStringSelection(const wxString& WXUNUSED(s)) { }
-
wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
protected:
return wxEmptyString;
}
-void wxComboBox::SetStringSelection(const wxString& selection)
-{
-}
-
void wxComboBox::Clear()
{
}
int wxComboBox::FindString(const wxString&) const
{
- return 0;
+ return wxNOT_FOUND;
}
int wxComboBox::GetSelection() const
// this destructor is required for Darwin
}
-// ----------------------------------------------------------------------------
-// selection
-// ----------------------------------------------------------------------------
-
-bool wxChoiceBase::SetStringSelection(const wxString& s)
-{
- int sel = FindString(s);
- wxCHECK_MSG( sel != -1, false,
- wxT("invalid string in wxChoice::SetStringSelection") );
-
- Select(sel);
-
- return true;
-}
-
// ----------------------------------------------------------------------------
// misc
// ----------------------------------------------------------------------------
return s;
}
+bool wxItemContainer::SetStringSelection(const wxString& s)
+{
+ const int sel = FindString(s);
+ if ( sel == wxNOT_FOUND )
+ return false;
+
+ Select(sel);
+
+ return true;
+}
+
wxArrayString wxItemContainer::GetStrings() const
{
wxArrayString result ;
EnableEvents();
}
-bool wxComboBox::SetStringSelection( const wxString &string )
-{
- wxCHECK_MSG( m_widget != NULL, false, wxT("invalid combobox") );
-
- int res = FindString( string );
- if (res == -1) return false;
- SetSelection( res );
- return true;
-}
-
wxString wxComboBox::GetValue() const
{
GtkEntry *entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry );
EnableEvents();
}
-bool wxComboBox::SetStringSelection( const wxString &string )
-{
- wxCHECK_MSG( m_widget != NULL, false, wxT("invalid combobox") );
-
- int res = FindString( string );
- if (res == -1) return false;
- SetSelection( res );
- return true;
-}
-
wxString wxComboBox::GetValue() const
{
GtkEntry *entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry );
return wxEmptyString;
}
-bool wxComboBox::SetStringSelection(const wxString& sel)
-{
- int s = FindString (sel);
- if (s > -1)
- {
- SetSelection (s);
- return true;
- }
- else
- return false;
-}
-
void wxComboBox::SetString(int n, const wxString& s)
{
m_choice->SetString( n , s ) ;
#endif
}
-bool wxComboBox::SetStringSelection(const wxString& sel)
-{
- int s = FindString (sel);
- if (s > -1)
- {
- SetSelection (s);
- return true;
- }
- else
- return false;
-}
-
void wxComboBox::SetString(int n, const wxString& s)
{
#if USE_HICOMBOBOX
return wxEmptyString;
}
-bool wxComboBox::SetStringSelection(const wxString& sel)
-{
- int s = FindString (sel);
- if (s > -1)
- {
- SetSelection (s);
- return true;
- }
- else
- return false;
-}
-
void wxComboBox::SetString(int n, const wxString& s)
{
m_choice->SetString( n , s ) ;