I want to change the text of second column of listview to bold, & secondly, I want to change the backcolor of row,when the user clicks on that row.
When we run the form first time,text of second column is bold.But when the user clicks on the row,backcolor is not changing & even text of second column changes to regular. Below is the mine code. Check it Out,where I m going wrong.

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim lvitem As ListViewItem
        Dim a As New Font("Arial", 8, FontStyle.Bold)
        lvitem = ListView1.Items.Add("1")
        lvitem.SubItems.Add("A")
        lvitem.SubItems(1).Font = a
        lvitem.UseItemStyleForSubItems = False


        lvitem = ListView1.Items.Add("2")
        lvitem.SubItems.Add("B")
        lvitem.SubItems(1).Font = a
        lvitem.UseItemStyleForSubItems = False

    End Sub

    Private Sub ListView1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.Click
        For Each lvitem As ListViewItem In ListView1.Items
            lvitem.UseItemStyleForSubItems = True
            If lvitem.Selected Then
                lvitem.BackColor = Color.Red
                Label1.Text = lvitem.SubItems(1).Text
            Else
                lvitem.BackColor = Color.White
            End If
            Application.DoEvents()
        Next
    End Sub

   
   
End Class

Excuse me!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.