click button event problem
I want to do a simple thing: create windows form with a button and get line drawn when I click button. So far no luck with button click event, e.g. how do I make that line be drawn via private void button1_Click(object sender, EventArgs e)?
Is there a more appropriate beginners forum or I can post here?
thanks
Jonas
namespace Example1_1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.SetStyle(ControlStyles.ResizeRedraw, true);
this.BackColor = Color.White;
}
public void OnPaint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
g.PageUnit = GraphicsUnit.Inch;
Pen blackPen = new Pen(Color.Black, 5 / g.DpiX);
g.DrawLine(blackPen, 0, 0, 1, 1);
}
private void button1_Click(object sender, EventArgs e)
{
Application.Run(new Onpaint());
}
}
}