NShape Programmer Tasks
Setting the Shape Color in the Design

<< Click to Display Table of Contents >>

Navigation:  Programmer Tasks > Changing the Shape Color Programmatically >

NShape Programmer Tasks
Setting the Shape Color in the Design

Previous pageReturn to chapter overviewNext page

Shape colors can be modified in the design either by modifying the respective color style or the fill style of the shape. Modifying the color style replaces this color with new one everywhere in the project. Modifying the fill style in the design affects all templates, shapes and other objects that refer to this style. Note that you cannot modify a style that you access from a shape, because IPlanarShape.FillStyle returns a read-only style interface.

How to Modify the Color of a Fill Style:

Identify the fill style used in the shape, fetch it from the design and assign it a different BaseColorStyle:

myProject.Design.FillStyles[myShape.FillStyle.Name].BaseColorStyle = myProject.Design.ColorStyles.Green;

How to Modify a Color Style:

Identify the color style used in the shape's fill style, fetch it from the design and assign it a different color:

myProject.Design.ColorStyles[myShape.FillStyle.BaseColorStyle.Name].Color = Color.LightGreen;