Problem with ComboBox in version 2.8.0 Topic is solved
Hello again,
yes the entries are directly sorted after insertion. The output of the last line is "d".
wxString s[] = {
_("d"),
_("c"),
_("b"),
_("a")
};
wxComboBox* itemComboBox32 = new wxComboBox( this, wxID_ANY, _("a"), wxDefaultPosition, wxSize(130, -1), 4, s, ~(wxCB_SORT)&(wxCB_DROPDOWN) );
itemComboBox32->SetStringSelection(_("a"));
cout << itemComboBox32->GetString(3) << endl;
yes the entries are directly sorted after insertion. The output of the last line is "d".
wxString s[] = {
_("d"),
_("c"),
_("b"),
_("a")
};
wxComboBox* itemComboBox32 = new wxComboBox( this, wxID_ANY, _("a"), wxDefaultPosition, wxSize(130, -1), 4, s, ~(wxCB_SORT)&(wxCB_DROPDOWN) );
itemComboBox32->SetStringSelection(_("a"));
cout << itemComboBox32->GetString(3) << endl;
Try using the default constructor :
This code works fine under Windows and the code you submitted too. The problem is not in this instructions it's somewhere else.
Code: Select all
wxString s[] = {
_("d"),
_("c"),
_("b"),
_("a")
};
wxComboBox* itemComboBox32 = new wxComboBox;
itemComboBox32->Create(this, wxID_ANY, _("a"), wxDefaultPosition, wxSize(130, -1), 4, s, wxCB_DROPDOWN);
itemComboBox32->SetStringSelection(_("a"));
cout << itemComboBox32->GetString(3) << endl;
First at all, thanks for your interest and help...
The default-constructor changes nothing on the behaviour. I agree that there must be somewhere else the problem, but where? Due to the 4 simple lines (where I think there is no mistake), the problem could appear because of
1. the linux distribution
2. or the wxWidgets configuration.
But then the question is, why is the Combo-Example running fine?
I've no idea
The default-constructor changes nothing on the behaviour. I agree that there must be somewhere else the problem, but where? Due to the 4 simple lines (where I think there is no mistake), the problem could appear because of
1. the linux distribution
2. or the wxWidgets configuration.
But then the question is, why is the Combo-Example running fine?
I've no idea
Last idea, have you tried appending them AFTER the combobox is created? Maybe that changes something.
- Jorgen
- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
I think you meant something like that, but anyway the last entry is "d" too...
wxComboBox* itemComboBox32 = new wxComboBox(this, wxID_ANY, _("a"), wxDefaultPosition, wxSize(130, -1), 0, NULL, wxCB_DROPDOWN );
wxArrayString as;
as.Alloc(4);
as.Add(_("d"),1);
as.Add(_("c"),1);
as.Add(_("b"),1);
as.Add(_("a"),1);
itemComboBox32->Append(as);
cout << itemComboBox32->GetString(3) << endl;
wxComboBox* itemComboBox32 = new wxComboBox(this, wxID_ANY, _("a"), wxDefaultPosition, wxSize(130, -1), 0, NULL, wxCB_DROPDOWN );
wxArrayString as;
as.Alloc(4);
as.Add(_("d"),1);
as.Add(_("c"),1);
as.Add(_("b"),1);
as.Add(_("a"),1);
itemComboBox32->Append(as);
cout << itemComboBox32->GetString(3) << endl;
What if you append them without the arraystring, every item individually?
??
Maybe the way wxArrayString Append is implemented, triggers a sort.
- Jorgen
Code: Select all
itemComboBox32->Append(_("d"));
itemComboBox32->Append(_("c"));
itemComboBox32->Append(_("b"));
itemComboBox32->Append(_("a"));
Maybe the way wxArrayString Append is implemented, triggers a sort.
- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
And you are sure the minimal sample or combobox sample is not displaying this same behaviour?
What if you place only the essential code (e.g. the creation of the combobox and the filling of it) in the minimal sample?
The only thing I can think of is that there is something goofy with the flags.
- Jorgen
What if you place only the essential code (e.g. the creation of the combobox and the filling of it) in the minimal sample?
The only thing I can think of is that there is something goofy with the flags.
- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
- ABX
- Can't get richer than this
- Posts: 810
- Joined: Mon Sep 06, 2004 1:43 pm
- Location: Poznan, Poland
- Contact:
Re: Problem with ComboBox in version 2.8.0
There was bug due to missing paranthesis which broke all wxUniv based implementations of wxComboBox (wxX11, wxMGL etc.).tigdra83 wrote:This entries are sorted, but the style is without the option wxCB_SORT.
Following change makes wxComboBox work as expected (at least in my wxMSWUniv build).tigdra83 wrote:Any idea to get rid of this problem?
http://cvs.wxwidgets.org/viewcvs.cgi/wx ... 56&r2=1.57
ABX
CVS Head, 2.8.X
wxMSW, wxWinCE, wxPalmOS, wxOS2, wxMGL, bakefile
gcc 3.2.3, bcc 5.51, dmc 8.48, ow 1.6, vc 7.1, evc 3/4, pods 1.2
wxMSW, wxWinCE, wxPalmOS, wxOS2, wxMGL, bakefile
gcc 3.2.3, bcc 5.51, dmc 8.48, ow 1.6, vc 7.1, evc 3/4, pods 1.2
strange
Hello again (back from holidays ),
I've tested your idea (in a circuitous way to see if it works really) and get to sorted combo-boxes:
//=================================
wxString strings[] = {_("d"),_("b"),_("c"), _("a")};
wxBoxSizer* bs = new wxBoxSizer(wxHORIZONTAL);
myFrame->SetSizer(bs);
wxComboBox* cb = new wxComboBox(this, wxID_ANY, _("a"), wxDefaultPosition, wxSize(130, -1), 4, strings, wxCB_DROPDOWN);
cb->SetStringSelection(_("a"));
cout << "style_1: " << cb->GetWindowStyle() << endl;
wxComboBox* cb2 = new wxComboBox(this,wxID_ANY,_(""), wxDefaultPosition, wxSize(130, -1), 4, strings, wxCB_READONLY|(cb->GetWindowStyle()&wxCB_SORT?0:0));
cout << "style_2: " << cb2->GetWindowStyle() << endl;
bs->Add(cb, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
bs->Add(cb2, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
//=================================
But I wonder because of the output, there are 2 different styles represented (but having no influence to the graphical representation...):
style_1: 33882144
style_2: 33882128
I've tested your idea (in a circuitous way to see if it works really) and get to sorted combo-boxes:
//=================================
wxString strings[] = {_("d"),_("b"),_("c"), _("a")};
wxBoxSizer* bs = new wxBoxSizer(wxHORIZONTAL);
myFrame->SetSizer(bs);
wxComboBox* cb = new wxComboBox(this, wxID_ANY, _("a"), wxDefaultPosition, wxSize(130, -1), 4, strings, wxCB_DROPDOWN);
cb->SetStringSelection(_("a"));
cout << "style_1: " << cb->GetWindowStyle() << endl;
wxComboBox* cb2 = new wxComboBox(this,wxID_ANY,_(""), wxDefaultPosition, wxSize(130, -1), 4, strings, wxCB_READONLY|(cb->GetWindowStyle()&wxCB_SORT?0:0));
cout << "style_2: " << cb2->GetWindowStyle() << endl;
bs->Add(cb, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
bs->Add(cb2, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
//=================================
But I wonder because of the output, there are 2 different styles represented (but having no influence to the graphical representation...):
style_1: 33882144
style_2: 33882128