Y
Yuelin
Hi, thanks for the answers to my previous questions.
Now I have a question on drawing in C#:
For example I have written following code to draw a rectangle on a form:
protected override void OnPaint ( PaintEventArgs e)
{
Graphics dc = e.Graphics;
Pen BluePen = new Pen(Volor.Blue, 3);
dc.DrawRectangle(BluePen, 0, 0, 50, 50);
base.OnPaint (e);
}
The reason I put the code in this method instead of puting it into the
constructor is that
I want to move and redraw the rectangle later. Also is it is because if I
put the drawing code in the
constructor the rectangle would be "erased" when I move another window (say,
Task Manager)
over the rectangle.
Now I want to re-position the rectangle, say move to (10, 20), whenever I
click it.
Presumebly I should put the code for redrawing into the following method:
private void OnMouseDownEvent(object sender, MouseEventArgs e)
But how can I call the OnPaint method from the OnMouseDownEvent method?
Anyone has ideas? Thanks.
Yuelin
Now I have a question on drawing in C#:
For example I have written following code to draw a rectangle on a form:
protected override void OnPaint ( PaintEventArgs e)
{
Graphics dc = e.Graphics;
Pen BluePen = new Pen(Volor.Blue, 3);
dc.DrawRectangle(BluePen, 0, 0, 50, 50);
base.OnPaint (e);
}
The reason I put the code in this method instead of puting it into the
constructor is that
I want to move and redraw the rectangle later. Also is it is because if I
put the drawing code in the
constructor the rectangle would be "erased" when I move another window (say,
Task Manager)
over the rectangle.
Now I want to re-position the rectangle, say move to (10, 20), whenever I
click it.
Presumebly I should put the code for redrawing into the following method:
private void OnMouseDownEvent(object sender, MouseEventArgs e)
But how can I call the OnPaint method from the OnMouseDownEvent method?
Anyone has ideas? Thanks.
Yuelin