Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Making a colored string

Making a colored string

Scheduled Pinned Locked Moved Visual Basic
tutorial
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Ballita
    wrote on last edited by
    #1

    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

    G S 2 Replies Last reply
    0
    • B Ballita

      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

      G Offline
      G Offline
      Gagan 20
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • B Ballita

        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

        S Offline
        S Offline
        Steven J Jowett
        wrote on last edited by
        #3

        Change the ForeColor property of the Label or TextBox 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.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups