列表视图项目不显示
是否有原因,当使用 listview1.View = View.Details
时,当我添加项目但让它们不可见时,我的列表视图会展开(生成滚动条),但是当我将其切换到 listview1 时,我的列表视图会展开(生成滚动条) .View = View.List
它工作得很好吗?
并不是说我认为这真的很重要,但这是我用来向列表视图添加项目的代码:
ListViewItem item1 = new ListViewItem(file[1]);
listView1.Items.Add(item1);
自动生成的设计器代码:
//
// listView1
//
this.listView1.CheckBoxes = true;
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.Path});
this.listView1.Location = new System.Drawing.Point(12, 44);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(457, 354);
this.listView1.TabIndex = 7;
this.listView1.UseCompatibleStateImageBehavior = false;
this.listView1.View = System.Windows.Forms.View.Details;
file 是一个字符串数组,第一个元素中包含大约 50 个奇数字符(使用调试器检查) 。
Is there a reason why when using listview1.View = View.Details
my listview will expand (generate scrollbars) when I add items but have them be invisible, but when I switch it over to listview1.View = View.List
it works just fine?
Not that I think that it really matters, but here is the code that I use to add items to the listview:
ListViewItem item1 = new ListViewItem(file[1]);
listView1.Items.Add(item1);
And the autogenerated designer code:
//
// listView1
//
this.listView1.CheckBoxes = true;
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.Path});
this.listView1.Location = new System.Drawing.Point(12, 44);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(457, 354);
this.listView1.TabIndex = 7;
this.listView1.UseCompatibleStateImageBehavior = false;
this.listView1.View = System.Windows.Forms.View.Details;
file is a string array that contains about 50 odd characters in the first element (checked using debugger).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
你在叫“清除”吗?如果是这样,请确保您调用的是
lv.Items.Clear()
而不是lv.Clear()
。Are you calling "Clear"? If so make sure you are calling
lv.Items.Clear()
and notlv.Clear()
.下面的代码应该可以工作:
如果没有,我就不知道了。您添加的字符串的字符是否可见?
The following code should work:
If it doesn't I have no clue. Are the characters of the string you are adding visible?
您需要添加一列才能使详细信息视图正常工作。
You need to add a column for Details view to work.
我遇到了同样的问题,在我的
listview
中看不到文本。当我使用代码克隆该项目时,该错误是我犯的;我不小心只重命名了第一部分,并再次将文本信息添加到第一个项目中,而不是克隆的项目中。我的意思是:错误:
正确:
I had the same problem, with not visible text in my
listview
. The error was made by me, when I cloned the item using code; I accidentally renamed only the first part and added text information again to the first items but not the cloned items. Here is what I mean:Wrong:
Right:
我也有同样的问题。
我已将列宽设置为 -2,以便它自动调整大小以适应列标题中文本的长度。当我切换到“详细信息”视图时,列宽自动重置为 0,从而隐藏了项目。
I had the same problem.
I had set the column width to -2 so it would auto size to the length of the text in the column header. When I switched to
Details
view the column width was automatically reset to 0, thereby hiding the items.只需将其添加到您的列表视图中即可。更改 listview1 你的列表视图名称:
Just add that to your Listview. Change listview1 your Listview name: