Hello,
I Want to draw a geometric object to the screen and then fill it. I can draw it, but don't come any further.
I have a button1_Click-Event:
- private void button1_Click(object sender, EventArgs e)
- {
- this.pictureBox1.Paint += new System.Windows.Forms.PaintEventHandler(this.FillEllipseRectangle);
- }
- private void FillEllipseRectangle(object sender, PaintEventArgs e)
- {
- MessageBox.Show("well done");
- ...
- }
I hope somebody can help me.

Amit GuptaRank #190 · 12.8K reputationPosted Nov 6, 2016, 7:55 AM EST
Dmitrij Solov43 reputationPosted Nov 6, 2016, 8:17 AM EST
Amit GuptaRank #190 · 12.8K reputationPosted Nov 6, 2016, 8:24 AM EST
Dmitrij Solov43 reputationPosted Nov 6, 2016, 8:33 AM EST
Amit GuptaRank #190 · 12.8K reputationPosted Nov 6, 2016, 8:45 AM EST
Dmitrij Solov43 reputationPosted Nov 7, 2016, 7:05 AM EST
Bikesh SrivastavaRank #108 · 20.3K reputationPosted Nov 7, 2016, 5:53 PM EST
Dmitrij Solov43 reputationPosted Nov 8, 2016, 9:59 AM EST
{
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.pictureBox1.Paint += new System.Windows.Forms.PaintEventHandler(this.FillEllipseRectangle);
}
private void FillEllipseRectangle(object sender, PaintEventArgs e)
{
MessageBox.Show("very well done!");
Pen itsme = new Pen(Color.Green, 3);
//Draw the ellipse
int x = 5;
int y = 5;
int width = 200;
int height = 100;
rect = new Rectangle(x, y, width, height);
e.Graphics.DrawEllipse(itsme, rect);
//Draw the ellipse
int x1= 5;
int y1 = 5;
int width1 = 200;
int height1 = 100;
rect1 = new Rectangle(x1, y1, width1, height1);
SolidBrush redBrush = new SolidBrush(Color.Red);
e.Graphics.FillEllipse(redBrush, this.rect1);
}
public System.Drawing.Rectangle rect { get; set; }
public System.Drawing.Rectangle rect1 { get; set; }
}
}