【问题标题】:How to change second column on specific item如何更改特定项目的第二列
【发布时间】:2016-10-08 16:22:51
【问题描述】:

如何更改特定项目的第二列 我的脚本

                    foreach (ListView item in lvVictumes.Items)
                {
                    if (item.Name == "devid")
                    {
                        item.SubItems[1].Text = "13";
                    }
                }

错误 CS1061“ListView”不包含“SubItems”的定义,并且找不到接受“ListView”类型的第一个参数的扩展方法“SubItems”(您是否缺少 using 指令或程序集引用?)

【问题讨论】:

  • SubItems 是 ListViewItem 的一个属性

标签: c# visual-studio


【解决方案1】:

ListView.Items propertyListViewItem(具有SubItems 属性)的集合,而不是ListView(不具有SubItems)的集合。

修复您的 foreach 行,其余的应该可以工作。

foreach (ListViewItem item in lvVictumes.Items)
{
    if (item.Name == "devid")
    {
        item.SubItems[1].Text = "13";
    }
}

【讨论】:

    【解决方案2】:

    您确定没有将 Windows 窗体 ListViewItem 与 WPF ListView 混淆吗? WPF 的ListView 没有子项。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-07-08
      • 2021-10-19
      • 1970-01-01
      • 1970-01-01
      • 2022-01-11
      • 2019-09-25
      • 2022-01-25
      相关资源
      最近更新 更多