Click here to Skip to main content
15,919,341 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Problems with windows...and vb.net Pin
Christian Graus11-Aug-05 12:56
protectorChristian Graus11-Aug-05 12:56 
GeneralRe: Problems with windows...and vb.net Pin
JimClark6812-Aug-05 3:44
JimClark6812-Aug-05 3:44 
GeneralRe: Problems with windows...and vb.net Pin
Steve Pullan11-Aug-05 13:27
Steve Pullan11-Aug-05 13:27 
GeneralRe: Problems with windows...and vb.net Pin
JimClark6812-Aug-05 3:52
JimClark6812-Aug-05 3:52 
GeneralRunning my projects in different computers. Pin
JimClark6811-Aug-05 7:17
JimClark6811-Aug-05 7:17 
GeneralRe: Running my projects in different computers. Pin
Dave Kreskowiak11-Aug-05 8:18
mveDave Kreskowiak11-Aug-05 8:18 
GeneralRe: Running my projects in different computers. Pin
JimClark6812-Aug-05 3:41
JimClark6812-Aug-05 3:41 
GeneralDraw string in different colors Pin
tibmark11-Aug-05 7:11
tibmark11-Aug-05 7:11 
I am trying to write a tooltip that can display a hyperlink or change the color of one word in a string. This what I have

Dim MainString As String = "This word is a different color"


Dim stringToChangeColor As String = "word"

Dim range() As CharacterRange = {New CharacterRange(MainString.IndexOf(stringToChangeColor), stringToChangeColor.Length)}
Dim format As New StringFormat
format.SetMeasurableCharacterRanges(range)
format.FormatFlags = StringFormatFlags.NoClip
Dim region(1) As Region
region = e.Graphics.MeasureCharacterRanges(MainString, Me.Font, New RectangleF(0, 0, Me.Width, Me.Height), format)
Dim rec As New RectangleF
rec = region(0).GetBounds(e.Graphics)

Dim stringB As New StringBuilder
stringB.Append(MainString)
stringB.Replace(stringToChangeColor, " ", stringB.ToString.IndexOf(stringToChangeColor), stringToChangeColor.Length)

rec.Width = rec.Width + 10
rec.X = rec.X - 2
rec.Y = 0

e.Graphics.DrawString(stringB.ToString, Me.Font, Brushes.Black, 0, 0)
e.Graphics.DrawString(stringToChangeColor, Me.Font, Brushes.Red, rec.X, rec.Y, format)
' e.Graphics.DrawString(MainString, Me.Font, Brushes.RoyalBlue, 0, 20)

The problem I have is that I have to manually set the number of spaces in the stringB.Replace.

Is there another way?

Please help.

Thanks in advance



Mark Thibodeaux
GeneralRe: Change color of a word in a string? Pin
Steve Pullan11-Aug-05 20:02
Steve Pullan11-Aug-05 20:02 
GeneralRe: Change color of a word in a string? Pin
tibmark12-Aug-05 2:45
tibmark12-Aug-05 2:45 
GeneralCombo box question Pin
dptalt11-Aug-05 5:10
dptalt11-Aug-05 5:10 
GeneralRe: Combo box question Pin
Anonymous11-Aug-05 10:53
Anonymous11-Aug-05 10:53 
GeneralRe: Combo box question Pin
dptalt12-Aug-05 3:12
dptalt12-Aug-05 3:12 
GeneralCombo box problem Pin
dptalt11-Aug-05 5:03
dptalt11-Aug-05 5:03 
GeneralRe: Combo box problem Pin
Christian Graus11-Aug-05 12:58
protectorChristian Graus11-Aug-05 12:58 
GeneralRe: Combo box problem Pin
dptalt12-Aug-05 3:36
dptalt12-Aug-05 3:36 
GeneralComboBox Pin
Scott Mitchell11-Aug-05 4:34
Scott Mitchell11-Aug-05 4:34 
GeneralLimiting decimal places Pin
utservoalius11-Aug-05 4:11
utservoalius11-Aug-05 4:11 
GeneralRe: Limiting decimal places Pin
rwestgraham11-Aug-05 8:28
rwestgraham11-Aug-05 8:28 
GeneralRe: Limiting decimal places Pin
utservoalius11-Aug-05 16:05
utservoalius11-Aug-05 16:05 
GeneralRe: Limiting decimal places Pin
rwestgraham11-Aug-05 16:20
rwestgraham11-Aug-05 16:20 
GeneralList machines on the network Pin
Duncan Edwards Jones11-Aug-05 3:43
professionalDuncan Edwards Jones11-Aug-05 3:43 
GeneralRe: List machines on the network Pin
Duncan Edwards Jones13-Aug-05 13:20
professionalDuncan Edwards Jones13-Aug-05 13:20 
Generalstored procedures Pin
Anonymous11-Aug-05 3:32
Anonymous11-Aug-05 3:32 
GeneralRe: stored procedures Pin
toxcct11-Aug-05 3:38
toxcct11-Aug-05 3:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.