hi frd,
I have draw a line between two table's item at a button click event.Line appear on the panel . Problem is when I try to draw line between two differnt table's item again then first created line disappear. How i can hold the old draw line on panel.with the new one.

10 Years
Discussion Span
Last Post by dangkytructuyen

if I would see the code I would give you a better answer. but I think what your problem is that you are drawing the line on onClick event. you have to draw it on onPaint event in order to keep them on form. otherwise it will draw the lines but when OS repaint the form they all will go away. in order to keep them on form you have to repaint them every time os paints the form which can be done by paint event. here is some sample code. I hope that would help.

private void DrawPanel_Load(object sender, EventArgs e)
            pen = new Pen(Color.Black, 3);

        private void DrawPanel_Paint(object sender, PaintEventArgs e)
            g = e.Graphics;
            //Drawing lines
            g.DrawLine(pen, 10, 245, 180, 245);
            g.DrawLine(pen, 10, 250, 10, 10);
            g.DrawLine(pen, 5, 10, 110, 10);

if you want to draw it on on click event just use a Boolean value to verify if you have to draw lines. change the value on onclick and use it on onPaint.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.