简体   繁体   English

如何填充wxListCtrl?

[英]How to populate wxListCtrl?

I'm trying to populate a wxListCtrl but after trying various methods can't seem to be able to populate it with items. 我正在尝试填充wxListCtrl但是尝试各种方法后似乎无法使用项目填充它。

Basically, I want a list control that would have three columns with headings and will show values in rows. 基本上,我想要一个列表控件,该控件具有三列标题,并在行中显示值。 But I've tried InsertItem, SetItem, or InsertColumn methods but am only able to show the column headings but not the row data. 但是我尝试了InsertItem,SetItem或InsertColumn方法,但是只能显示列标题,而不能显示行数据。 Any help will be greatly appreciated! 任何帮助将不胜感激! Thanks in advance! 提前致谢!

You can add columns like this: 您可以像这样添加列:

int column_width = 90;
my_list_ctrl->InsertColumn(0, L"ColumnText", wxLIST_FORMAT_LEFT, column_width);

You can add items like this: 您可以添加以下内容:

int image_index = 0;
long list_index = my_list_ctrl->InsertItem(0, L"My Item text", image_index);

You can set the text of the subitems like this: 您可以这样设置子项目的文本:

int column_index = 1;
my_list_ctrl->SetItem(list_index, column_index, L"Text");

You can setup an image list for your list like this: 您可以像这样为列表设置图像列表:

my_list_ctrl->SetImageList(&img_list, wxIMAGE_LIST_SMALL);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM