How to change the color of a subitem of a listview item?

  • Thread starter Thread starter Kuehiong Tu
  • Start date Start date
K

Kuehiong Tu

Is there any way to change only the ForeColor and
BackColor of a subitem of a listview item? That means
if the listview is displayed in detailed mode, only one
field of a listview item has a different color instead of
the whole row.
..
 
Here's a quick VB.Net sample...

Dim lvi As ListViewItem
Dim f As Font
f = New Font(ListView1.Font, FontStyle.Bold)
Dim bgc As System.Drawing.Color
bgc = ListView1.BackColor
Dim lColor As System.Drawing.Color
lColor = System.Drawing.Color.Blue
Dim uf As New Font(f, FontStyle.Underline)
lvi = ListView1.Items.Add("Test")
lvi.UseItemStyleForSubItems = False
lvi.ForeColor = lColor
lvi.Font = uf
lvi.SubItems.Add("Different Color")
lvi.SubItems.Add("Same Color")
lvi.SubItems.Add("Another", System.Drawing.Color.Red, bgc, f)
lvi.SubItems.Add("Blue", System.Drawing.Color.DodgerBlue, bgc, f)

Jerry
 
Back
Top