Hi,
I have a wxEditableListBox, which looks like the screenshot below. Is there a way the border drawn can be changed? The box containing the New, Edit and Delete buttons looks like it can be edited! But in reality, it is just for displaying the label.
Can i change that border to a non-3D border? Please help!
wxEditableListBox - border issue
Re: wxEditableListBox - border issue
Looking into the source code, there is definitely no easy or "official" way to do it, the border style is hard coded.
The only way would be to find the panel among the children of the control and try to change its border style. Possible, but i'm not sure if it's worth the effort.
Or you could just change it in the wxWidgets source and rebuild.
The only way would be to find the panel among the children of the control and try to change its border style. Possible, but i'm not sure if it's worth the effort.
Or you could just change it in the wxWidgets source and rebuild.
Use the source, Luke!
Re: wxEditableListBox - border issue
I think "hacking" would be much easier then modifying the library source code and all things coming from diverging from the official wxWidgets source. It is just a couple lines of code and should be quite safe. Whether it's worth it...
Code: Select all
#include <wx/wx.h>
#include <wx/editlbox.h>
class MyFrame : public wxFrame
{
public:
MyFrame() : wxFrame(NULL, wxID_ANY, "Test", wxDefaultPosition, wxSize(600, 400))
{
const wxString label = "First one";
wxPanel* mainPanel = new wxPanel(this);
wxBoxSizer* mainPanelSizer = new wxBoxSizer(wxVERTICAL);
wxEditableListBox* elb = new wxEditableListBox(mainPanel, wxID_ANY, label);
wxWindow* labelWnd = FindWindowByLabel(label, elb);
if ( labelWnd && dynamic_cast<wxStaticText*>(labelWnd) )
{
wxPanel* labelWndParent = dynamic_cast<wxPanel*>(labelWnd->GetParent());
if ( labelWndParent && labelWndParent->HasFlag(wxBORDER_SUNKEN) )
{
labelWndParent->ToggleWindowStyle(wxBORDER_SUNKEN);
labelWndParent->ToggleWindowStyle(wxBORDER_SIMPLE);
}
}
mainPanelSizer->Add(elb, 1, wxALL | wxEXPAND, 10);
elb = new wxEditableListBox(mainPanel, wxID_ANY, "Second one");
mainPanelSizer->Add(elb, 1, wxALL | wxEXPAND, 10);
mainPanel->SetSizer(mainPanelSizer);
}
};
class MyApp : public wxApp
{
public:
bool OnInit()
{
(new MyFrame)->Show();
return true;
}
}; wxIMPLEMENT_APP(MyApp);
Re: wxEditableListBox - border issue
Superb! I love this forum...makes life so much easier.
Thanks a lot PB, and to all of you who help us with wxWidgets!
Thanks a lot PB, and to all of you who help us with wxWidgets!