willsonlincake 发表于 2022-4-9 17:23:19

wxWidgets双栏视图

#include "WxListView2Frame.h"
#include <wx/panel.h>
#include <wx/listctrl.h>
#include <wx/sizer.h>

WxListView2Frame::WxListView2Frame(const wxString& title)
    : wxFrame(NULL, wxID_ANY, title)
{
    // Create a top-level panel to hold all the contents of the frame
    wxPanel* panel = new wxPanel(this, wxID_ANY);

    // Create a wxListView control with one column.
    // The default style is wxLC_REPORT so columns need
    // to be added explicitly.
    wxListView* listView = new wxListView(panel, wxID_ANY,
      wxDefaultPosition, wxSize(250, 200));
    listView->AppendColumn("Column 1");
    listView->AppendColumn("Column 2");

    // Add three items to the list
    listView->InsertItem(0, "Item 1");
    listView->SetItem(0, 1, "Amber");
    listView->InsertItem(1, "Item 2");
    listView->SetItem(1, 1, "Blue");
    listView->InsertItem(2, "Item 3");
    listView->SetItem(2, 1, "Cyan");

    // Set up the sizer for the panel
    wxBoxSizer* panelSizer = new wxBoxSizer(wxHORIZONTAL);
    panelSizer->Add(listView, 1, wxEXPAND);
    panel->SetSizer(panelSizer);

    // Set up the sizer for the frame and resize the frame
    // according to its contents
    wxBoxSizer* topSizer = new wxBoxSizer(wxHORIZONTAL);
    topSizer->Add(panel, 1, wxEXPAND);
    SetSizerAndFit(topSizer);
}

Starrry 发表于 2022-4-9 17:58:26

这个好像是C++.

willsonlincake 发表于 2022-4-9 18:01:05

Starrry 发表于 2022-4-9 17:58
这个好像是C++.

就是
页: [1]
查看完整版本: wxWidgets双栏视图