Hi, Can anyone give me an answer to this problem I am facing. Here is the code:
When I run this code, how come it won't draw a rectangle in the Form1() constructor, but it will when i click on the button?
Any way of making it being able to draw it on the Form1() constructor?
I am having to call a timer with a 10ms interval at the moment to make it draw.
Regards,
Martin
Computing Design And Services:
Code:
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
Graphics g;
Brush solBrush = new SolidBrush(Color.Blue);
public Form1()
{
InitializeComponent();
g = pictureBox1.CreateGraphics();
g.FillRectangle(solBrush, 10, 10, 100, 30);
}
private void button1_Click(object sender, EventArgs e)
{
g.FillRectangle(solBrush, 10, 10, 100, 30);
}
}
}
Any way of making it being able to draw it on the Form1() constructor?
I am having to call a timer with a 10ms interval at the moment to make it draw.
Regards,
Martin
Computing Design And Services: