ilhami caliskan

ilhami caliskan

  • NA
  • 76
  • 89.5k

draw line in user control?

Oct 17 2013 2:50 PM

 
Hi All,
can anybody ell me why I cant draw this line in a user controller?
with the same code I can draw line in a simple form, but not in controller...


any help?

 

namespace DrawingLine
{
    public partial class Counter : UserControl
    {
        public Counter()
        {
            InitializeComponent();
        }

        public void DrawLine(int x1, int y1, int x2, int y2)
        {
            System.Drawing.Pen myPen;
            myPen = new System.Drawing.Pen((System.Drawing.Color.Red), 10);
            System.Drawing.Graphics line = this.CreateGraphics();
            line.DrawLine(myPen, x1, y1, x2, y2);

            myPen.Dispose();
            line.Dispose();
        }       
    }
}


Answers (1)