Solved

highlight new items in listbox

Posted on 2004-04-05
8
264 Views
Last Modified: 2012-05-04
Is it possible to set the text format to bold for individual rows in a list box?

I am trying to recreate something like Outlook in an Access form, and so I want new entries in the list box to appear in bold, until they are clicked on (like new emails are in bold in Outlook). Is this possible?
0
Comment
Question by:mlittler
  • 3
  • 3
8 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 10756119
Not sure if that is possible, because I think the font properties apply to all entries in a listbox

Have you thought of using the FlexGrid, its more powerful because of its formatting features
or maybe the listview control (reference "Microsoft Widows Common Controls" )
0
 
LVL 65

Accepted Solution

by:
rockiroads earned 500 total points
ID: 10756131
create a listview control on your form

and here is some sample code which populates it

    Dim li As ListItem
    With lstView
        .View = lvwReport
        .HideColumnHeaders = True
        .ColumnHeaders.Add , , "Column1"
        .ListItems.Add , "Row1", "Row1"
        .ListItems.Add , "Row2", "Row2"
        .ListItems.Add , "Row3", "Row3"
       
    End With
   
    For Each li In lstView.ListItems
        If li.Text = "Row2" Then
            li.ForeColor = vbRed
            li.Bold = True
        End If
    Next

'Note a selected row is put in bold and coloured Red

0
 
LVL 12

Expert Comment

by:nexusnation
ID: 10758640
try modifying the code above to find the selected item and unbold it.

    For Each li In lstView.ListItems
        If li.Text = "Row2" Then
        li.Bold = False
    Next


            li.ForeColor = vbRed
            li.Bold = True
        End If
    Next
0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
LVL 12

Expert Comment

by:nexusnation
ID: 10758641
try modifying the code above to find the selected item and unbold it.

    For Each li In lstView.ListItems
        If li.Text = "Row2" Then
        li.Bold = False
    Next


            li.ForeColor = vbRed
            li.Bold = True
        End If
    Next
0
 
LVL 12

Expert Comment

by:nexusnation
ID: 10758653
oops, that was a mispost.

   For Each li In lstView.ListItems
        If li.Text = Me.lstView.ItemData(Me.lstView.Selected(x)) Then
           li.Bold = False
           Exit For
        End If
    Next

I don't know (or even think) that this will work because I used some properties/collections that I don't think that are for list view, but I'm not sure.

Andrew
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 10758688
I created a sample form and put that code in, it seems to work for me
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

785 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