Change the default text that shows up when creating a new Text shape

Applies to: Nevron Diagram for .NET

How to change the default text that shows up when creating a new Text shape?

The text shape created by the Create Text Tool is instanced by the CreateText method of the NDiagramElementFactory class. An instance of this class can be get/set by the drawing view ElementFactory property. You need to subclass the NDiagramElementFactory class and override the CreateText method. Currently the code of this method is:

[C#]
public virtual NTextShape CreateText(bool preview)
{
    NTextShape text = new NTextShape();
    text.Text = "Double click and type your text";
    return text;
}

[VB.NET]
Public Overridable Function CreateText(preview As Boolean) As NTextShape
    Dim text As New NTextShape()
    text.Text = "Double click and type your text"
    Return text
End Function

Change the default text as you wish. Then create an instance of your subclassed class and set it to the ElementFactory property.

Article ID: 32, Created On: 10/5/2010, Modified: 11/15/2010