locked
How can I create rounded curve label in Winforms? RRS feed

  • Question

  • Hello,

     

    How can I create Label control with rounded curve in my Winforms?. Could you please give me the steps.

     

    Thanks,

    K.R.Vivekanandan

    Saturday, April 21, 2007 1:16 PM

Answers

  • Use the code that Binny gave you but instead of AddEllipse, use 4 x AddArc() and AddLine().  You'll also want to set AutoSize = False, TextAlign = MiddleCenter and give the label a distinct BackColor.
    Saturday, April 21, 2007 2:30 PM

All replies

  • using System.Drawing.Drawing2D;

     

    private void MakeLabelRounded() {

        GraphicsPath gp = new GraphicsPath();

        gp.AddEllipse(0, 0, label1.Width, label1.Height);

        label1.Region = new Region(gp);

        label1.Invalidate();

    }

    Saturday, April 21, 2007 1:45 PM
  • Hello Binny,

    Thanks Binny. Sorry i want to convert Label as rounded rectangle shape. But graphics allow only rectangle shape.Could you please give the another way to achieve this?.

     

    Thanks,

    K.R.Vivekanandan

    Saturday, April 21, 2007 2:11 PM
  • Use the code that Binny gave you but instead of AddEllipse, use 4 x AddArc() and AddLine().  You'll also want to set AutoSize = False, TextAlign = MiddleCenter and give the label a distinct BackColor.
    Saturday, April 21, 2007 2:30 PM
  • Hello Nobugz,

     

    Thanks for your time being help.I implemented rounded rectangle by using AddArc and AddLine.

     

    Thanks,

    K.R.Vivekanandan

    Sunday, April 22, 2007 10:32 AM