Making a colored string
-
Hi, I have a string and I want to make my string 'blue' through my code. Can anyone tell me how to do that.
Thanks & Regards Mishra
Try the following code :
Dim g As Graphics = Me.Creategraphics 'or use other control on which you are drawing ur string.
Dim str As String = "Your String"
Dim myfont As New Font("Times New Roman", 16, FontStyle.Regular)
Dim txtsize As SizeF
txtsize = g.MeasureString(str, myfont)
Dim rect As RectangleF = New RectangleF(New PointF(0, 0), txtsize)
Dim mybrush As Brush = New LinearGradientBrush(rect, Color.Blue, Color.Blue, LinearGradientMode.ForwardDiagonal)
g.DrawString(str, myfont, mybrush, New Point(20,20))Hope,you got what you wanted!
Gagan
-
Hi, I have a string and I want to make my string 'blue' through my code. Can anyone tell me how to do that.
Thanks & Regards Mishra
Change the ForeColor property of the
Label
orTextBox
that you use to display the string value.myLabel.ForeColor = System.Drawing.Color.Blue
Steve Jowett ------------------------- Real programmers don't comment their code. If it was hard to write, it should be hard to read.