Solved

color and bold in listview row

Posted on 2004-09-08
7
2,052 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
Technology Partners: 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!

 
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

Industry Leaders: 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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month11 days, 11 hours left to enroll

623 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