Solved

Multi colored labels

Posted on 2009-05-07
2
153 Views
Last Modified: 2012-05-06
I need to display a label about 45 characters in length.  It needs to alternate certain letters using two colors.
For example "On the first Friday..."  I need all letters to be white by default and the n and both t's to be grey.  I do not mind using multiple labels so long as the spacing somehow justifies so the spacing does not look strange.  Please provide a sample routine that can accept a string, Thank You.

I also have a routine that uses DrawString.  VB5 does not like that or the dim statements assigning a new font in the same instruction.  If you can provide a substitute for the instructions below that VB5 will accept and I can get it to work (or your own routine), I will still award you all the points, Thank You

     Dim DefaultFont As New Font("arial", 10, FontStyle.Regular)
      Dim BlueString As New SolidBrush(System.Drawing.Color.Blue)
      Dim RedString As New SolidBrush(System.Drawing.Color.Red)
      Dim gr As Graphics
      Dim OfficeIdentifier as string = "Office:"
      Dim LocationIdentifier as string

      LocationIdentifier = "Toronto"

      gr = LabelOffice.CreateGraphics
      gr.DrawString(OfficeIdentifier , rf, BlueString , 1, 1)
      gr.DrawString(LocationIdentifier , rf, RedString , 40, 1)

0
Comment
Question by:GarySB
2 Comments
 
LVL 22

Accepted Solution

by:
danaseaman earned 500 total points
ID: 24330255
See this free Formatted Label control which allows HTML style tags which can change Font attributes and colors.

http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=34507&lngWId=1


0
 

Author Closing Comment

by:GarySB
ID: 31579086
Thank You!!! I updated to vb6 since I needed the additional functionality.  It Works!!!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

920 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

13 Experts available now in Live!

Get 1:1 Help Now