Solved

highlight new items in listbox

Posted on 2004-04-05
8
256 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MS Access creating a Chart from Search result on Form view 2 21
Direct Mail software 4 44
Search Form not Querying 2 11
Error: Operation must use an updateable query 2 11
Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

895 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

18 Experts available now in Live!

Get 1:1 Help Now