Multi colored labels
Posted on 2009-05-07
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)