NShape Programmer Tasks
Changing Shape Properties Programmatically

<< Click to Display Table of Contents >>

Navigation:  Programmer Tasks >

NShape Programmer Tasks
Changing Shape Properties Programmatically

Previous pageReturn to chapter overviewNext page

A shape's properties are defined by three entities: The shape itself, its template and the design assigned to the project. Read "Templates" and "Styles" to understand these concepts. When you want to change a shape property you must consider these points:

If the property is not a style, set the property directly in the shape:

myShape.Text = "Hello World!";

If the property is a style but you want to detach it from the template and modify it just for the shape in question, set the respective style property:

myShape.LineStyle = myProject.Design.LineStyles.Dotted;

If the property is a style and you want to change it for shapes of the same template, set the respective style property in the template:

myShape.Template.Shape.LineStyle = myProject.Design.LineStyles.Dotted;

If you want the change the style for all shapes and templates using it, reference it in the design and set its properties:

myProject.Design.LineStyles.Dotted.DashStyle = DashDot;

See Also

Changing the Shape Color Programmatically