6
Answers

Fill a Rectangle in Windows Application C#

Ask a question
ayesha ahmad

ayesha ahmad

11y
2.4k
1
hi,

I have made a rectangle on my windows form using Rectangle Class.
Problem is that its width is 200 and height is 100.
I only want to fill the 4th part of rectangle means 50px out of total width 200px with brown colour.


System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(Color.Brown);
Rectangle rec = new Rectangle(0, 0, 200, 100);
System.Drawing.Graphics formGraphics = this.CreateGraphics();
formGraphics.FillRectangle(myBrush, rec);


Any help will be highly appericated


Thanks


Answers (6)