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
Solved

highlight new items in listbox

Posted on 2004-04-05
8
272 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to set Excel's default SaveAs folder, from Access VBA 6 42
Error can't find table ?? 5 24
UK Date format in MS Access 4 21
Populating datasheet subform from VBA 6 14
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…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

856 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