YellowFlash
YellowFlash

Reputation: 139

I want to draw String(which is actually a number) inside a circle?

I want to add String(1-10) inside a circle? Here is the code for the circle

e.Graphics.DrawEllipse(Pens.Black, 210, 100, 240, 220)

Here is the string i want to insert

Dim ls_str as String = "5"

Is there any way to do this???

Upvotes: 0

Views: 630

Answers (1)

Jens
Jens

Reputation: 6375

Use the Graphics.DrawString and the Graphics.MeasureString methods.

Like so

Dim StringSize as SizeF = e.Graphics.MeasureString(ls_str, Font) 'Use the font you want
e.Graphics.DrawString(ls_str, Font, CInt(210 + 240 / 2 - StringSize.Width / 2), _  
                                    CInt(100 + 220 / 2 - StringSize.Height / 2))

This draws the string in the center of the ellipse that you used. Adjust the coordinates accordingly.

Upvotes: 1

Related Questions