我正在尝试将ListView项或ListView中的特定列设置为粗体。这是我的代码,但它没有工作,所以我要求帮助,以使其工作。
Do While dr.Read = True
x = New ListViewItem(dr("ID").ToString)
x.UseItemStyleForSubItems = False
x.SubItems.Add(dr("full_name"))
x.SubItems(1).Font = New Font(New FontFamily("Arial"), 16, FontStyle.Bold)
x.SubItems.Add(dr("address"))
x.SubItems.Add(dr("city"))
ListView1.Items.Add(x)
Loop
答案 0 :(得分:0)
我刚刚测试了这段代码,它对我有用:
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
For i = 1 To 10
Dim item As New ListViewItem(i.ToString())
item.UseItemStyleForSubItems = False
Dim subitem = item.SubItems.Add(i.ToString())
subitem.Font = New Font(New FontFamily("Arial"), 16, FontStyle.Bold)
item.SubItems.Add(i.ToString())
ListView1.Items.Add(item)
Next
End Sub
End Class
你的代码还有别的东西。