【问题标题】:c# Retrieve reference to Project Resources (VS2008)c# 检索对项目资源的引用 (VS2008)
【发布时间】:2008-11-28 11:29:25
【问题描述】:

我目前有一个列表视图,我想为每个条目添加一个适当的图标。

我在项目资源中创建了一个图标并将其命名为“errorIcon.ico”。如何引用此图标/资源并在列表视图中使用它?

【问题讨论】:

    标签: c# visual-studio-2008 listview icons


    【解决方案1】:

    首先您需要创建一个ImageList 实例,参见http://msdn.microsoft.com/en-us/library/system.windows.forms.imagelist.aspx(只需将其放在您的表单/用户控件上)。使用属性视图将您的图标上传到图像列表。

    然后,将图像列表分配给每个 ListViewItem (listViewItem.ImageList = imageList) 并设置图标索引 (listViewItem.ImageIndex = 0)

    更多信息请看这里的备注:http://msdn.microsoft.com/en-us/library/system.windows.forms.listviewitem.imageindex.aspx

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多