简体   繁体   中英

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.

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. 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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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