【问题标题】:How can I have a Listview display multiple columns?如何让 Listview 显示多列?
【发布时间】:2016-02-10 07:45:35
【问题描述】:

我正在尝试制作一个 ListView,其中包含每个图像下方的图像及其标签。我使用LargeIcon 显示模式,因为Tile 显示并排显示标签和图像。我的问题是它没有显示尽可能多的列,就像在这个屏幕截图中它会适合两列而不是一列:

[

【问题讨论】:

  • 不清楚您想要实现的方式。另外,能否提供代码示例?
  • 您可能只缺少一个或太多像素..
  • 哦。好像 ListView 项由于某种原因需要太多右边的空间,It works now,谢谢。

标签: c# listview windows-forms-designer


【解决方案1】:

我认为这可能有助于在您的表单设计器中添加名称为 lView1 的 listView 的新控件。

lView1.View = View.Details;
Add your columns
        lView1.Columns.Add("ID");
        lView1.Columns.Add("Name");

Add the listview items
        lView1.Items.Add(new ListViewItem(new string[]{"1", "name1"}));
        lView1.Items.Add(new ListViewItem(new string[]{"4", "name2"}));
        lView1.Items.Add(new ListViewItem(new string[]{"2", "name3"}));

【讨论】:

  • 最后,一些真正有效的东西。大多数在 stackoverflow 上接受的旧答案在 2019 年都不起作用。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-08-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-01-26
相关资源
最近更新 更多