Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Can some one help me to find this....
Posted
Updated 4-Dec-19 17:26pm

Have a look here: Text on Path with VB.NET[^]
 
Share this answer
 
It's difficult to answer without more information, primarily I'd need to know what constraints you have on the spacing.

If you're just trying to evenly space the text all around the circle then something like this might do the trick for you;

C#
using System;
using System.Drawing;
using System.Windows.Forms;

namespace CircleText {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
            SizeChanged += (s, e) => Invalidate();
        }

        protected override void OnPaint(PaintEventArgs e) {
            base.OnPaint(e);

            var center = new Point(Width/2, Height/2);
            var radius = Math.Min(Width, Height) / 3;
            var text = "ABCDEFGHIJLKMNOPQRSTUVWXYZ";

            var font = new Font(FontFamily.GenericSansSerif, 24, FontStyle.Bold);
            for (var i = 0; i < text.Length; ++i)
            {
                var c = new String(text[i], 1);

                var size = e.Graphics.MeasureString(c, font);
                var charRadius = radius + size.Height;

                var angle = (((float)i / text.Length) - 0.25) * 2 * Math.PI;

                var x = (int)(center.X + Math.Cos(angle) * charRadius);
                var y = (int)(center.Y + Math.Sin(angle) * charRadius);


                e.Graphics.TranslateTransform(x, y);

                e.Graphics.RotateTransform((float)(90 + 360 * angle / (2 * Math.PI)));
                e.Graphics.DrawString(c, font, Brushes.Red, 0, 0);

                e.Graphics.ResetTransform();


                e.Graphics.DrawArc(new Pen(Brushes.DarkGreen, 2.0f), center.X - radius, center.Y - radius, radius*2, radius*2, 0, 360);
            }
   }
    }
}


Hope this helps
 
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