Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

color and bold in listview row

Posted on 2004-09-08
7
Medium Priority
?
2,064 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 54

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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 400 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
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 …
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…

971 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