wxListCtrl简单使用

来源:互联网 发布:pickit2烧写软件 编辑:程序博客网 时间:2024/05/22 06:21

这里写图片描述

核心代码:

Simple::Simple(const wxString& title) :wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(450,400)){    wxPanel* panel = new wxPanel(this, wxID_ANY);    //wxListCtrl* listCtrl = new wxListCtrl(panel, wxID_ANY, wxPoint(50, 50), wxDefaultSize, wxLC_REPORT | wxDOUBLE_BORDER);    m_item_list = new wxListCtrl(panel, wxID_ANY, wxPoint(10,10), wxDefaultSize, wxLC_REPORT);    m_item_list->SetForegroundColour(wxColour(0, 255, 0));    m_item_list->SetBackgroundColour(wxColour(0, 0, 0));    // Add first column           wxListItem col0;    col0.SetId(0);    col0.SetText(_("Foo"));    col0.SetWidth(100);    m_item_list->InsertColumn(0, col0);    // Add second column    wxListItem col1;    col1.SetId(1);    col1.SetText(_("Name"));    col1.SetWidth(100);    m_item_list->InsertColumn(1, col1);    // Add third column         wxListItem col2;    col2.SetId(2);    col2.SetText(_("Comments"));    col2.SetWidth(100);    m_item_list->InsertColumn(2, col2);    wxButton* button = new wxButton(panel, wxID_ANY, "add",wxPoint(314,9));    button->Bind(wxEVT_BUTTON, &Simple::OnButtonClick, this);    this->Centre();}Simple::~Simple(){}void Simple::OnButtonClick(wxCommandEvent& event){    static int i = 0;    m_item_list->InsertItem(i, "");    m_item_list->SetItem(i, 0, "ID");    m_item_list->SetItem(i, 1, "worker");    m_item_list->SetItem(i, 2, "value");    ++i;}
0 0
原创粉丝点击