windows Winform 列表视图列未显示
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4997451/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Winform listview columns not showing up
提问by jvcoach23
I'm trying to put a listview on a VS 2010, vb.net winform form. I
1. drug the listview from the toolbox to the form.
2. right cick and did an edit columns
3. added two columns with the names of (chLocationID, chLocation) and the text of LocationID and Location.
4. when i click ok, nothing shows up in the listview designer.
我正在尝试在 VS 2010、vb.net winform 表单上放置一个列表视图。I 1. 将工具箱中的列表视图添加到表单中。
2. 右键单击并编辑列 3. 添加了名称为 (chLocationID, chLocation) 的两列以及 LocationID 和 Location 的文本。4. 当我单击确定时,列表视图设计器中没有显示任何内容。
In the code behind i did a for loop to add some data.
在后面的代码中,我做了一个 for 循环来添加一些数据。
For Each O In oS
Dim itm As New ListViewItem
itm.SubItems.Add(O.tblLocationID.ToString)
itm.SubItems.Add(O.Location)
itm.Tag = O
lvLocation.Items.Add(itm)
Next
when i step through the code.. it says that it adds the row.. a lvLocation.items.count give me a value of 1.. which is correct but nothing displays on the screen.
当我逐步执行代码时.. 它说它添加了行.. lvLocation.items.count 给我的值为 1.. 这是正确的,但屏幕上没有显示任何内容。
So.. I've done something wrong.. just not sure what?
所以..我做错了什么..只是不确定是什么?
回答by Justin Denton
Make sure the ListView's View property is set to Details - either in the designer or in code. Winforms ListViews only show their columns in Details view.
确保 ListView 的 View 属性设置为 Details - 无论是在设计器中还是在代码中。Winforms ListViews 仅在详细信息视图中显示它们的列。