如何在wxListCtrl中设置sizer
我想创建一个框架,其中包含一个面板,其下有一个wxListCtrl
,当我最小化或最大化框架时,Listctrl
不依赖于Frame.so。谁能告诉我如何使我的 wxListCtrl 框架依赖。 我知道 sizer 可以在这里工作,我使用了它,我想我使用它的方式是错误的。我的代码是:
Id_Search_Report::Id_Search_Report(const wxString &title)
:wxFrame (NULL,1,title,wxDefaultPosition,wxSize(985,650),wxDEFAULT_FRAME_STYLE)
{
/*
\---------------------------------------------------------------------------------
INITIALIZAION OF COUNTER WITH 0
---------------------------------------------------------------------------------
*/
this->counter=0;
/*
---------------------------------------------------------------------------------
CALLING PANEL CONSTRUCTOR
---------------------------------------------------------------------------------
*/
panel_first =new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL,wxT(""));
wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL);
panel_first->SetSizer(vbox);
/*
---------------------------------------------------------------------------------
CALLING LIST CONTROL CONSTRUCTOR
---------------------------------------------------------------------------------
*/
data_list_control= new wxListCtrl(panel_first, wxID_ANY, wxPoint(0,0), wxDefaultSize, wxLC_REPORT,wxDefaultValidator);
vbox->Add(data_list_control,1,wxEXPAND);
/*
---------------------------------------------------------------------------------
CALLING CLOSE BUTTON CONSTRUCTOR
---------------------------------------------------------------------------------
*/
submit=new wxButton(panel_first,41,BUTTON_CLOSE ,wxPoint(880,620), wxDefaultSize);
back =new wxButton(panel_first, 42,BUTTON_BACK ,wxPoint(880,630), wxDefaultSize);
/*
---------------------------------------------------------------------------------
CREATING EVENT FOR CLOSE BUTTON CLICKED
---------------------------------------------------------------------------------
*/
Connect(41, wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(Id_Search_Report::onbuttonclick));
/*
---------------------------------------------------------------------------------
INITIALIZATION OF LIST CONTROL COLOUMN
INSERT COLOUMN PARAMETERS ARE:-(ID, HEADER TEXT, ALLIGNMENT(2 FOR MIDDLE)
---------------------------------------------------------------------------------
*/
data_list_control->InsertColumn(0,COLOUMN_1,2);
//data_list_control->SetColumnWidth(0, 80);
data_list_control->InsertColumn(1,COLOUMN_2,2);
//data_list_control->SetColumnWidth(1, 80);
data_list_control->InsertColumn(2,COLOUMN_3,2);
//data_list_control->SetColumnWidth(2, 80);
data_list_control->InsertColumn(3,COLOUMN_4,2);
//data_list_control->SetColumnWidth(3, 80);
data_list_control->InsertColumn(4,COLOUMN_5,2);
//data_list_control->SetColumnWidth(4, 80);
data_list_control->InsertColumn(5,COLOUMN_6,2);
//data_list_control->SetColumnWidth(5, 80);
data_list_control->InsertColumn(6,COLOUMN_7,2);
//data_list_control->SetColumnWidth(6, 80);
data_list_control->InsertColumn(7,COLOUMN_8,2);
//data_list_control->SetColumnWidth(7, 80);
data_list_control->InsertColumn(8,COLOUMN_9,2);
//data_list_control->SetColumnWidth(8, 80);
data_list_control->InsertColumn(9,COLOUMN_10,2);
//data_list_control->SetColumnWidth(9, 80);
data_list_control->InsertColumn(10,COLOUMN_11,2);
//data_list_control->SetColumnWidth(10, 80);
data_list_control->InsertColumn(11,COLOUMN_12,2);
//data_list_control->SetColumnWidth(11, 80);
//sizer
}
I want to create a frame , which contains a panel and under that it has a wxListCtrl
, when I minimize or maximize the frame, Listctrl
is not dependent on Frame.so. Can anybody tell me how I can make my wxListCtrl frame dependent.
I know sizer will work here I used it, I think I used it in wrong way. my code is:
Id_Search_Report::Id_Search_Report(const wxString &title)
:wxFrame (NULL,1,title,wxDefaultPosition,wxSize(985,650),wxDEFAULT_FRAME_STYLE)
{
/*
\---------------------------------------------------------------------------------
INITIALIZAION OF COUNTER WITH 0
---------------------------------------------------------------------------------
*/
this->counter=0;
/*
---------------------------------------------------------------------------------
CALLING PANEL CONSTRUCTOR
---------------------------------------------------------------------------------
*/
panel_first =new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL,wxT(""));
wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL);
panel_first->SetSizer(vbox);
/*
---------------------------------------------------------------------------------
CALLING LIST CONTROL CONSTRUCTOR
---------------------------------------------------------------------------------
*/
data_list_control= new wxListCtrl(panel_first, wxID_ANY, wxPoint(0,0), wxDefaultSize, wxLC_REPORT,wxDefaultValidator);
vbox->Add(data_list_control,1,wxEXPAND);
/*
---------------------------------------------------------------------------------
CALLING CLOSE BUTTON CONSTRUCTOR
---------------------------------------------------------------------------------
*/
submit=new wxButton(panel_first,41,BUTTON_CLOSE ,wxPoint(880,620), wxDefaultSize);
back =new wxButton(panel_first, 42,BUTTON_BACK ,wxPoint(880,630), wxDefaultSize);
/*
---------------------------------------------------------------------------------
CREATING EVENT FOR CLOSE BUTTON CLICKED
---------------------------------------------------------------------------------
*/
Connect(41, wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(Id_Search_Report::onbuttonclick));
/*
---------------------------------------------------------------------------------
INITIALIZATION OF LIST CONTROL COLOUMN
INSERT COLOUMN PARAMETERS ARE:-(ID, HEADER TEXT, ALLIGNMENT(2 FOR MIDDLE)
---------------------------------------------------------------------------------
*/
data_list_control->InsertColumn(0,COLOUMN_1,2);
//data_list_control->SetColumnWidth(0, 80);
data_list_control->InsertColumn(1,COLOUMN_2,2);
//data_list_control->SetColumnWidth(1, 80);
data_list_control->InsertColumn(2,COLOUMN_3,2);
//data_list_control->SetColumnWidth(2, 80);
data_list_control->InsertColumn(3,COLOUMN_4,2);
//data_list_control->SetColumnWidth(3, 80);
data_list_control->InsertColumn(4,COLOUMN_5,2);
//data_list_control->SetColumnWidth(4, 80);
data_list_control->InsertColumn(5,COLOUMN_6,2);
//data_list_control->SetColumnWidth(5, 80);
data_list_control->InsertColumn(6,COLOUMN_7,2);
//data_list_control->SetColumnWidth(6, 80);
data_list_control->InsertColumn(7,COLOUMN_8,2);
//data_list_control->SetColumnWidth(7, 80);
data_list_control->InsertColumn(8,COLOUMN_9,2);
//data_list_control->SetColumnWidth(8, 80);
data_list_control->InsertColumn(9,COLOUMN_10,2);
//data_list_control->SetColumnWidth(9, 80);
data_list_control->InsertColumn(10,COLOUMN_11,2);
//data_list_control->SetColumnWidth(10, 80);
data_list_control->InsertColumn(11,COLOUMN_12,2);
//data_list_control->SetColumnWidth(11, 80);
//sizer
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在我看来,你实际上并没有创建一个框架。虽然您继承了 wxFrame() 类,但尚未创建框架。我会
先打电话给你框架。然后,为了清楚起见,您可能需要使用类似的东西来引用该框架,
而不是使用 this 指针,并将面板放在该框架的顶部。
希望有帮助
It seems to me that you have not actually created a frame. Though you inherited the wxFrame() class, you haven't created the frame. I would call
before anything else to give you the frame first. Then it you might want to reference this frame with something like
for clarity instead of using the this pointer and put your panel on top of this frame.
hope that helps
据我了解您的问题,您想要更改控件的大小,因为用户更改了顶部框架的大小。
为此,您需要响应 fram 更改大小时生成的 sizer 事件。像这样的东西:
As I understand your queation you want to change the size of your controls as the size of the top fram is altered by the user.
To do this, you need to respond to sizer events generated when the fram changes size. Something like this: