简体   繁体   English

紧凑框架C#:listView子项

[英]compact framework C#: listView sub item

I have to change the fore color of Listview Subitem in listview . 我必须在listview中更改Listview子项的前景色。

I m using WM6 C#, can u plze help me out. 我正在使用WM6 C#,请您帮我一下。 Hw can change the colors of Subitems indivudally? 硬件可以分别更改子项的颜色吗?

Plz help me... 请帮我...

Thanks in Advance 提前致谢

The only way to do this is to custom draw the items. 唯一的方法是自定义绘制项目。 Christian Helle has an example here (it's way too long to post back here). 克里斯蒂安·海勒Christian Helle)在这里有个例子 (在这里发帖太久了)。

I wanted something like this in my app, but Mobile screens are small. 我希望在我的应用中找到类似的内容,但移动设备的屏幕很小。 It worked better to set the entire ListViewItem 's BackColor property: 设置整个ListViewItemBackColor属性效果更好:

private void ChangeLviColor(ListViewItem lvi, Color color) {
  if (lvi.BackColor != color) {
    lvi.BackColor = color;
  }
}

FYI: Both of the links above will take you to some great sample code. 仅供参考:上面的两个链接都将带您进入一些出色的示例代码。

Of special note, be aware of this remark: "If you want to use the same background color for all subitems of an item, set the UseItemStyleForSubItems property to true. This will cause the colors and fonts specified for the item to be used for all subitem text." 需要特别注意的是: “如果要为项目的所有子项目使用相同的背景色,请将UseItemStyleForSubItems属性设置为true。这将导致为该项目指定的颜色和字体用于所有项目。子项目文字。”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM