Solved

color and bold in listview row

Posted on 2004-09-08
7
2,027 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
  • 3
  • 2
7 Comments
 
LVL 49

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now