添加到列表视图后无颜色 [英] No color after add in listview
本文介绍了添加到列表视图后无颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Public Sub Add_In_ListView(ByVal Field1 As String, ByVal Field2 As String, ByVal Field3 As String, ByVal Field4 As String, ByVal Field5 As String, ByVal Field6 As String, ByVal Field7 As Boolean)
lv = ListView1.Items.Add(Field1)
lv.SubItems.Add(Field2)
lv.SubItems.Add(Field3)
lv.SubItems.Add(Field4)
lv.SubItems.Add(Field5)
lv.SubItems.Add(Field6)
If Field7 = True Then
lv.SubItems.Add(6).Text = "Enable"
lv.SubItems(6).ForeColor = Color.Green
Else
lv.SubItems.Add(6).Text = "Disable"
lv.SubItems(6).ForeColor = Color.Red
End If
lv.SubItems.Add("")
lv.SubItems.Add("")
lv.SubItems.Add("")
lv.SubItems.Add("")
lv.SubItems.Add("")
ListView1.Refresh()
End Sub
当我的子例程运行正确添加时,在listviw中,带有单词enable或disable的行并没有改变颜色.
为什么?
谢谢和问候
Mea culpa
我忘记了
lv.UseItemStyleForSubItems = False
抱歉!
When my subroutine run add correctly the line with the word enable or disable in the listviw BUT they did not change the color.
Why???
Thanks and regards
Mea culpa
I have forget the
lv.UseItemStyleForSubItems = False
Sorry!
推荐答案
找到的分辨率:对于ListViewItem
变量lv
,将属性UseItemStyleForSubItems
设置为false
.
根据MSDN关于属性ForeColor
和BackColor
的主题:
如果拥有子项目的 已测试.ListViewItem
的UseItemStyleForSubItems
属性设置为true,则设置此属性无效.
祝你好运.
—SA
The resolution found: for theListViewItem
variablelv
, set the propertyUseItemStyleForSubItems
tofalse
.
According to MSDN on the topic of propertiesForeColor
andBackColor
:
If the Tested.UseItemStyleForSubItems
property of theListViewItem
that owns the subitem is set to true, setting this property has no effect.
Good luck.
—SA
这篇关于添加到列表视图后无颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文