Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change font color in a checkedlistbox

Status
Not open for further replies.

basbrian

Programmer
Feb 18, 2002
49
0
0
AU
Hi, I am trying to change the color of some lines in a checkedlistbox(CLB). I have included the code that I use to load the CLB and some code that I have found that changes the color in a list view box. Is it possible to change the color of the font in a CLB? I am very new with VB.net and still trying to work out how things are done.

Code:
Dim cnalldels As New SqlConnection(connectionString)
        Dim ssqlalldels As String = "SELECT DISTINCT del_code, xdesc = case when code3 > 0 then del_code + '                    ' + descript when code2 > 0 then del_code + '            ' + descript when code1 > 0 then del_code + '    ' + descript end FROM coffsdelegation_type order by del_code"
        Dim daptalldels As New SqlDataAdapter(ssqlalldels, cnalldels)

        cnalldels.Open()
        If Not dsalldels.Tables("post") Is Nothing Then
            dsalldels.Tables("post").Clear()
        End If
        daptalldels.Fill(dsalldels, "post")

        CLBDelegations.DataSource = Nothing
        CLBDelegations.DataSource = dsalldels.Tables("post")
        CLBDelegations.DisplayMember = "xdesc"
        CLBDelegations.ValueMember = "del_code"
        CLBDelegations.SelectedIndex = -1
'''''''''''''''''''''''''''''''''''''''''''''''''''
        Dim i As Integer = 0
        Dim oItem As ListViewItem
        With ListView1
            .Columns.Add("Hi")
            .Columns(0).Width = 100
            .CheckBoxes = True

            For i = 1 To 10
                oItem = .Items.Add("Hello " & i)
                ' Toggle Color every other line for example
                If i Mod 2 = 0 Then
                    oItem.ForeColor = Color.Red
                Else
                    oItem.ForeColor = Color.Blue
                End If
            Next
        End With
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top