Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to draw the following text on panel
sample text
how can i do that?

What I have tried:

Dim path As GraphicsPath = New GraphicsPath()

       Dim emSize As Single = 120
       path.AddString("sample text", font.FontFamily, CInt(font.Style), emSize, rect, format)

       g.FillPath(Brushes.Yellow, path)
       g.DrawPath(Pens.Black, path)
Posted
Updated 26-Oct-18 19:54pm

1 solution

To do that you would need to use several different FillPath and DrawPath command combinations, each with a different brush set. That's going to be very messy and quite difficult to implement as you will need to separate out each block of contiguous words that needs to be in a colour set, draw it, then use Graphics.MeasureString or GraphicsPath.GetBounds (probably the later) to find out how much space it took up, so you can use that as part of the offset to the next text block.

There will probably be a fair amount of iteration going on during this development; I wouldn't expect it to look perfect the first time I tried it, so I doubt you should either! :laugh:
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900