C#多列列表框

C#多列列表框,c#,winforms,list,listbox,C#,Winforms,List,Listbox,我有两个代码 List<string> _items = new List<string>(); List<string> _items2 = new List<string>(); 谢谢你以上答案对我不起作用,使用.NetCF时,这个微小的变化确实: myListView.Columns.Add("Nr"); //column 1 heading myListView.Columns.Add("Desc"); //column

我有两个代码

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

谢谢你

以上答案对我不起作用,使用.NetCF时,这个微小的变化确实:

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
}

使用Listview有什么问题吗?因为它比ListBox更灵活。我认为一个列表框中不能有两列。我认为您需要一个listView或DataGridView。使用两个ListBox可能会更容易,因为这两个列表之间似乎没有任何共同之处。ListBox的一个属性称为“Multicolumn”@CocoaDev您可以参考msdn文档中的multilistbox列,但我强烈建议使用ListView OP使用的是ListBox控件,而不是ListView。
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
}