Changing Backcolor of a rectangle

Hello,

I can’t manage to change Backcolor of a rectangle I created dynamically.


Rectangle rect = pres.Slides[currentSlide].Shapes.AddRectangle(x,y,width,height);
rect.FillFormat.BackColor = System.Drawing.Color.RosyBrown;


I only managed to change Fillformat.Forecolor but Backcolor seems read-only

thanks

Stephane

Dear Stephane,

You should set FillType at first.
When FillType has NoFill value then all properties are read-only.

how can I set the filltype ?

Dear Stephane,

Rectangle rect = …
rect.FillFormat.Type = FillType.Pattern;
rect.FillFormat.PatternStyle = PatternStyle.DiagonalBrick;
rect.FillFormat.ForeColor = Color.Red;
rect.FillFormat.BackColor = Color.Blue;

Also I’d suggest to check our Northwind demo and Programmer’s guide in the Wiki.
It has good examples how to work with fill styles.