I wrote a code to draw a line in form by clicking on a button.
Please download in and tell me why it does not work.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Hirendra SisodiyaPosted Jul 23, 2010, 7:22 AM
add use invalidate() function for curing this problem..
you can cal this function on button click event like this
private void button1_Click(object sender, EventArgs e)
{
Form1 f = new Form1();
base.Paint+=new PaintEventHandler(Form1_Paint);
this.Invalidate();
}
thanks
Please mark as answer if it helps
Majid KamaliPosted Jul 24, 2010, 11:53 AM
Hirendra SisodiyaPosted Jul 23, 2010, 7:33 AM
Majid KamaliPosted Jul 23, 2010, 7:13 AM
Majid KamaliPosted Jul 22, 2010, 12:07 PM
I want to do that with PaintEventArgs way to not to become cleaned.
2. What does Dispose() do ?
3. Sorry for bad English ;-)
Mahesh ChandPosted Jul 22, 2010, 11:03 AM
I added a line to Kirtan's code.
private void button1_Click(object sender, EventArgs e)
{
Graphics g = this.CreateGraphics();
Pen p = new Pen(Color.Red, 1.0f);
g.DrawLine(p, 10, 40, 100, 100);
g.Dipose();
}
Kirtan PatelPosted Jul 22, 2010, 10:14 AM
void Form1_Paint(object sender, PaintEventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
Graphics g = this.CreateGraphics();
Pen p = new Pen(Color.Red, 1.0f);
g.DrawLine(p, 10, 40, 100, 100);
}
it will work