954,514 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

remind the draw line on panel

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.

jainendra.shah
Light Poster
44 posts since May 2008
Reputation Points: 10
Solved Threads: 0
 

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
            pen.Width=10;
            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.

yilmazhuseyin
Light Poster
48 posts since Oct 2006
Reputation Points: 31
Solved Threads: 5
 

Thanks you, I understant.

-------------------------------
Vietnam travel, Vietnam tour, Vietnam trip, Vietnam Vacation
(+844) 281 2760 / 246 1089
http://greentravel.com.vn

dangkytructuyen
Newbie Poster
1 post since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You