wxcombobox with several rows Topic is solved
wxcombobox with several rows
I have a comboboax which is filled with app. 60 items, what I need is that all are shown at once, so it should have multiple columns.
Is that somehow possible?
Is that somehow possible?
Re: wxcombobox with several rows
Hi,
Are you looking for wxListBox?
Thank you.
Are you looking for wxListBox?
Thank you.
Re: wxcombobox with several rows
Not really:
What I want, the selected should stand in the ctrl, like it is by the combobox.
However when i click on it and all the options get shown, it should not only be one column, it should be multiple colums. As there are a lot of values, it should be splitted into more colums.
What I want, the selected should stand in the ctrl, like it is by the combobox.
However when i click on it and all the options get shown, it should not only be one column, it should be multiple colums. As there are a lot of values, it should be splitted into more colums.
Re: wxcombobox with several rows
I believe wxComboBox does not support this feature out of the box (nor does the underlying native control on MSW).
However, you can use a list view with a wxComboCtrl: bundled combo sample actually has it on display.
However, you can use a list view with a wxComboCtrl: bundled combo sample actually has it on display.
Re: wxcombobox with several rows
Thanks for the combo ctrl advice,that works.
Also I have some questions for it.
How can I manage that it will automatically extend to show all items?
And how can I place a line between the colums?
Also I have some questions for it.
How can I manage that it will automatically extend to show all items?
And how can I place a line between the colums?
Re: wxcombobox with several rows
Hi,
Can you show some code?
Are you using wxListView in report mode?
Thank you.
Can you show some code?
Are you using wxListView in report mode?
Thank you.
Re: wxcombobox with several rows
I did take it out of the combo example
Re: wxcombobox with several rows
Code: Select all
class ListViewComboPopup : public wxListView, public wxComboPopup
{
public:
virtual void Init() wxOVERRIDE
{
m_value = -1;
m_itemHere = -1; // hot item in list
}
virtual bool Create(wxWindow* parent) wxOVERRIDE
{
return wxListView::Create(parent, 1,
wxPoint(0, 0), wxDefaultSize,
wxLC_LIST | wxLC_SINGLE_SEL |
wxSIMPLE_BORDER);
}
virtual wxWindow* GetControl() wxOVERRIDE { return this; }
virtual void SetStringValue(const wxString& s) wxOVERRIDE
{
int n = wxListView::FindItem(-1, s);
if (n >= 0 && n < GetItemCount())
wxListView::Select(n);
}
virtual wxString GetStringValue() const wxOVERRIDE
{
if (m_value >= 0)
return wxListView::GetItemText(m_value);
return wxEmptyString;
}
//
// Popup event handlers
//
// Mouse hot-tracking
void OnMouseMove(wxMouseEvent& event)
{
// Move selection to cursor if it is inside the popup
int resFlags;
int itemHere = HitTest(event.GetPosition(), resFlags);
if (itemHere >= 0)
{
wxListView::Select(itemHere, true);
m_itemHere = itemHere;
}
event.Skip();
}
// On mouse left, set the value and close the popup
void OnMouseClick(wxMouseEvent& event)
{
m_value = m_itemHere;
wxInt16 mywin;
mywin = event.GetId();
if (mywin == 9190)
{
wxString test;
test = "he";
}
else if (mywin == 9191)
{
wxString test;
test = "he";
}
else if (mywin == 9192)
{
wxString test;
test = "he";
}
else if (mywin == 9193)
{
wxString test;
test = "he";
}
// TODO: Send event
Dismiss();
}
//
// Utilies for item manipulation
//
void AddSelection(const wxString& selstr)
{
wxListView::InsertItem(GetItemCount(), selstr);
}
protected:
int m_value; // current item index
int m_itemHere; // hot item in popup
private:
wxDECLARE_EVENT_TABLE();
};
Code: Select all
class wxComboCtrlWithCustomPopupAnim : public wxComboCtrl
{
protected:
virtual bool AnimateShow(const wxRect & rect, int WXUNUSED(flags)) wxOVERRIDE
{
wxWindow* win = GetPopupWindow();
win->SetSize(rect);
win->Raise(); // This is needed
win->ShowWithEffect(wxSHOW_EFFECT_BLEND);
return true;
}
};
Code: Select all
wxBEGIN_EVENT_TABLE(ListViewComboPopup, wxListView)
EVT_MOTION(ListViewComboPopup::OnMouseMove)
// NOTE: Left down event is used instead of left up right now
// since MSW wxListCtrl doesn't seem to emit left ups
// consistently.
EVT_LEFT_DOWN(ListViewComboPopup::OnMouseClick)
wxEND_EVENT_TABLE()
Code: Select all
//verse
lv_vname = new wxComboCtrlWithCustomPopupAnim();
lv_vname->SetTextCtrlStyle(wxTE_RIGHT);
lv_vname->Create(tb1);
lv_vname->UseAltPopupWindow();
lv_vname->SetId(ID_lv_vname);
lv_vname->SetPopupMinWidth(100);
lv_vname->SetInitialSize(wxSize(60, 30));
iface_vn = new ListViewComboPopup();
lv_vname->SetPopupControl(iface_vn);
wxComboCtrl::GetFeatures();
count = 1;
while (count<=maxkap)
{
wxString newh;
newh << count;
iface_vn->AddSelection(newh);
count++;
}
iface_vn->Fit();
help = "";
help << suvnr[jetwin] - 1;
iface_vn->Select(wxAtoi(help), true);
lv_vname->SetText(help);
tb1->AddControl(lv_vname);
Re: wxcombobox with several rows
Hi,
You list view needs to be in report mode. Then you will have lines between columns.
And maybe you sizing issue will be fixed as well.
Thank you.
You list view needs to be in report mode. Then you will have lines between columns.
And maybe you sizing issue will be fixed as well.
Thank you.
Re: wxcombobox with several rows
in report mode I did get the background visible, so that each item background is only white as big as the item is. there was no other changes, and in overall it was not showing so smooth.
Re: wxcombobox with several rows
Hi,
Not sure what you mean.
Can you make a screenshot?
Also, what platform are you testing it on?
Thank you.
Not sure what you mean.
Can you make a screenshot?
Also, what platform are you testing it on?
Thank you.
Re: wxcombobox with several rows
I'm using windows.
One problem I found in listview, the popup does not get automatically bigger as the initial ctrl, what i need.
Screenshots only later, will be away until tomorrow evening.
One problem I found in listview, the popup does not get automatically bigger as the initial ctrl, what i need.
Screenshots only later, will be away until tomorrow evening.
Re: wxcombobox with several rows
But you can (1) compute the ideal list size since you know the item count and can get item rects and (2) set the pop-up size, can't you?
OTOH, I would have thought that report mode was not suitable when the columns should contain only items and not subitems: one would not be able to select the items (i.e., "cells"), only whole rows.
Re: wxcombobox with several rows
@PB,
The OP wanted the divider between the columns.
Maybe it is possible to somehow get the column for the row selected?
I didn't look at the API too close.
Thank you.
The OP wanted the divider between the columns.
Maybe it is possible to somehow get the column for the row selected?
I didn't look at the API too close.
Thank you.
Re: wxcombobox with several rows
I know that the OP wants the column separator; however, I believe that this cannot be really achieved with a wxLC_LIST wxListCtrl. And if wxLC_REPORT is used: one can get the item clicked as the programmer, but as the user, I would find odd that I can highlight only an item group (= row) and not an individual item...