Solved

color and bold in listview row

Posted on 2004-09-08
7
2,046 Views
Last Modified: 2013-12-25
hi all,

i hav a form that having a listview to display data from database.

wat i need is to make the certain row of the listview to appear in certain color or bold in certain conditions.

for e.g
select case x
case x = 1
    'listview row in blue
case x = 2
    'listview row in red
case x = 3
    'listview row in bold
end select

n etc.can this be done in listview?

thx in advance.

rgds,
daniel
0
Comment
Question by:daniellyh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
7 Comments
 
LVL 52

Expert Comment

by:Ryan Chong
ID: 12012692
Try like:

Private Sub Command1_Click()
    ListView1.ListItems.Clear
    For i = 1 To 30
        ListView1.ListItems.Add i, , "item " & i
        Select Case i Mod 3
        Case 0
            ListView1.ListItems(i).ForeColor = vbRed
            ListView1.ListItems(i).Bold = True
        Case 1
            ListView1.ListItems(i).ForeColor = vbBlue
            ListView1.ListItems(i).Bold = True
        Case 2
            ListView1.ListItems(i).ForeColor = vbBlack
        End Select
    Next i
End Sub

Try customize above example and apply your logic there.

Hope this helps
0
 
LVL 15

Expert Comment

by:ameba
ID: 12014900
Or, if row has more than one column:

Private Sub Form_Click()
    Dim k As Integer, itmx As ListItem
   
    Set itmx = Me.ListView1.ListItems(2)
    With itmx
        .ForeColor = vbRed   ' first column
        .Bold = True
        For k = 1 To .ListSubItems.Count ' other columns
            .ListSubItems(k).ForeColor = vbBlue
            .ListSubItems(k).Bold = True
        Next
    End With
End Sub
0
 
LVL 1

Author Comment

by:daniellyh
ID: 12022757
hi all,
thx for ur help n let me some times to try on it..thx.

rgds,
daniel
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 1

Author Comment

by:daniellyh
ID: 12332980
hi ameba,
i've try n it seem like not working when i set the listview to lvwreport?

rgds,
daniel
0
 
LVL 15

Accepted Solution

by:
ameba earned 100 total points
ID: 12333074
It should work in VB6 (or VB5) with component "Microsoft Windows Common Controls 6 (SP4)".  If you have older project which uses version 5, you can upgrade to version 6, or use APIs for version 5.
0
 
LVL 1

Author Comment

by:daniellyh
ID: 12335525
hi,
ok let me spend some times trying it. i will be at outstation this few days.

rgds,
daniel
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Hide vba in gp 7 127
Advice in Xamarin 21 121
pop out of webbrowser1 control vba6 5 52
how to Classify of email (pdf attachments) 7 57
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question