C#多列列表框 [英] C# MultiColumn Listbox

查看:913
本文介绍了C#多列列表框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个以下代码

    List<string> _items = new List<string>();
    List<string> _items2 = new List<string>();



我想他们都加入到一个多列列表框

I want to add both of them into a single multi-column Listbox

列1可能是_items而列2可以是_items2

Column1 could be _items whereas Column2 can be _items2

我不知道如何items2添加到第2列

I don't know how to add items2 to a 2nd column

我用

Listbox1.DataSource = _items

感谢您

推荐答案

以上回答并没有为我工作,使用.NetCF,这个微小的变化所做的:

The above answer did not work for me, using .NetCF, this slight variation did:

myListView.Columns.Add("Nr"); //column 1 heading
myListView.Columns.Add("Desc"); //column 2 heading
myListView.View = View.Details; //make column headings visible
foreach (var item in someDataList) //item has strings for each column of one row
{
    // create new ListViewItem
    ListViewItem lvi = new ListViewItem(item.Text1);
    lvi.SubItems.Add(item.Text2);
    // add the listviewitem to a new row of the ListView control
    myListView.Items.Add(lvi); //show Text1 in column1, Text2 in col2
}

这篇关于C#多列列表框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆