开发者

C++ : How to populate the second column of a listview via code

I have a listview with 2 columns. I can easily populate the first column by using:

commandHistory->Items->Add("Column 1 Entry S开发者_C百科uccessful!");

But how would I go about populating the second column at the same time?


Use the SubItems property. Like this:

             ListViewItem^ item = commandHistory->Items->Add("Frist!");
             item->SubItems->Add("2nd column");


You want to use a ListViewItem.

Here's an example:

ListView^ lv = gcnew ListView();
lv->Columns->Add("Language");
lv->Columns->Add("Creator");
ListViewItem^ a = gcnew ListViewItem(gcnew array<String^> { L"C++", L"Stroustrup" });
ListViewItem^ b = gcnew ListViewItem(gcnew array<String^> { L"Java", L"Gosling" });
lv->Items->AddRange(gcnew array<ListViewItem^> { a, b }); 
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜