Mysql 如何在数据值较低时突出显示ListView中的行
我希望发生的是,当Mysql 如何在数据值较低时突出显示ListView中的行,mysql,vb.net,listview,Mysql,Vb.net,Listview,我希望发生的是,当列表视图中某个项目的数量小于10时,该行的背景色将发生变化。下面的代码只更改最后一行的背景色。请帮忙 Dim list1 As New ListViewItem() Dim blank As List(Of String) = New List(Of String) Dim product As List(Of String) = New List(Of String) Private Sub LoadDatabase() productR
列表视图中某个项目的数量
小于10时,该行的背景色将发生变化。下面的代码只更改最后一行的背景色。请帮忙
Dim list1 As New ListViewItem()
Dim blank As List(Of String) = New List(Of String)
Dim product As List(Of String) = New List(Of String)
Private Sub LoadDatabase()
productReport.Items.Clear()
command.CommandText = "SELECT Product_Code, Product_Name, Quantity, Unit, Category, Location, Description FROM tblProduct"
command.Connection = connect
adapter.SelectCommand = command
reader = command.ExecuteReader()
While reader.Read
list1 = productReport.Items.Add(reader.GetString(0))
list1.SubItems.Add(reader.GetString(1))
list1.SubItems.Add(reader.GetString(2))
list1.SubItems.Add(reader.GetString(3))
list1.SubItems.Add(reader.GetString(4))
list1.SubItems.Add(reader.GetString(5))
list1.SubItems.Add(reader.GetString(6))
quantity.Add(reader.GetValue(2))
blank.Add(reader.GetString(4))
End While
reader.Close()
End Sub
Public Sub viewCritical()
Dim a = productReport.Items.Count
For x As Integer = 0 To productReport.Items.Count - 1
a = a - 1
If (quantity.Item(a) < 15) Then
list1.SubItems(a).BackColor = Color.LightCoral
Label1.Show()
End If
If (blank.Item(a) = "") Then
list1.SubItems(a).BackColor = Color.LightGreen
Label3.Show()
End If
Next
End Sub
Dim list1作为新的ListViewItem()
变暗空白为列表(字符串)=新列表(字符串)
Dim product As List(字符串的数量)=新列表(字符串的数量)
专用子加载数据库()
productReport.Items.Clear()
command.CommandText=“从TBL产品中选择产品代码、产品名称、数量、单位、类别、位置、说明”
command.Connection=connect
adapter.SelectCommand=command
reader=command.ExecuteReader()
边读边读
list1=productReport.Items.Add(reader.GetString(0))
list1.SubItems.Add(reader.GetString(1))
list1.SubItems.Add(reader.GetString(2))
list1.SubItems.Add(reader.GetString(3))
list1.SubItems.Add(reader.GetString(4))
list1.SubItems.Add(reader.GetString(5))
list1.SubItems.Add(reader.GetString(6))
quantity.Add(reader.GetValue(2))
blank.Add(reader.GetString(4))
结束时
reader.Close()
端接头
公共次视图临界()
Dim a=productReport.Items.Count
对于x作为整数=0的productReport.Items.Count-1
a=a-1
如果(a)项数量小于15,则
列表1.子项(a).BackColor=Color.LightCoral
Label1.Show()
如果结束
如果(空白。项目(a)=“”),则
列表1.子项(a).BackColor=Color.LightGreen
Label3.Show()
如果结束
下一个
端接头
默认情况下,所有子项使用相同的前景色/背景色/字体
要允许每个子项都有自己的属性,需要将ListViewItem.UseItemStyleForSubItems
设置为false