开发者

how to set sizer in wxListCtrl

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),wxD开发者_Python百科EFAULT_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


    }


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

 wxFrame::Create( parent, id, caption, pos, size, style )

before anything else to give you the frame first. Then it you might want to reference this frame with something like

Id_Search_Report *myFrame = this;

for clarity instead of using the this pointer and put your panel on top of this frame.

hope that helps


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:

EVT_SIZE(Id_Search_Report::OnSize)

void MyFrame::OnSize(wxSizeEvent& )
{
  if( data_list_control) {
    data_list_control->SetSize(GetClientRect());
  }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜