Solved

highlight new items in listbox

Posted on 2004-04-05
8
281 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
[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
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

707 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