Applies to: Nevron Diagram for .NET

How to change the text style of a diagram shape?



You can modify the FontStyle property and FillStyle property attached to the NTextStyle object – for example:

[C#]

NShape shape = new NRectangleShape(300, 300, 100, 100);
nDrawingDocument1.ActiveLayer.AddChild(shape);
 
shape.Text = "Shape 1";
 
NTextStyle textStyle;
if (shape.Style != null && shape.Style.TextStyle != null)
{
    textStyle = shape.Style.TextStyle;               
}
else
{
    textStyle = shape.ComposeTextStyle();
    NStyle.SetTextStyle(shape, textStyle);
}
 
textStyle.FontStyle = new NFontStyle("Verdana", 10, FontStyle.Bold | FontStyle.Italic);
textStyle.FillStyle = new NColorFillStyle(Color.FromArgb(60, 90, 108));

[VB.NET]
Dim shape As NShape = New NRectangleShape(300, 300, 100, 100)
NDrawingDocument1.ActiveLayer.AddChild(shape)
 
shape.Text = "Shape 1"
 
Dim textStyle As NTextStyle
If shape.Style IsNot Nothing AndAlso shape.Style.TextStyle IsNot Nothing Then
    textStyle = shape.Style.TextStyle
Else
    textStyle = shape.ComposeTextStyle()
    NStyle.SetTextStyle(shape, textStyle)
End If
 
textStyle.FontStyle = New NFontStyle("Verdana", 10, FontStyle.Bold Or FontStyle.Italic)
textStyle.FillStyle = New NColorFillStyle(Color.FromArgb(60, 90, 108))

This will change the text color and will make the text bold and italic at the same time.


Article ID: 36, Created On: 10/5/2010, Modified: 5/9/2011