My problem is how to draw a simple line in a child window in C#, i.e. :
- I have a parent window, with a button. Clicking the button, a child window shows,and a line is drawn on it.
Well, how do I do that ? This is my code for child window:
public partial class Form2 : Form
{
Pen pen;
public Form2()
{
InitializeComponent();
pen = new Pen(Color.Black);
}
private void Form2_Paint(object sender, PaintEventArgs e)
{
Graphics g;
g = this.CreateGraphics();
e.Graphics.DrawLine(pen, 10, 10, 100, 100);
}
}
Thanks.