We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

What are my options for creating a custom symbol? How do I make it respond to mouse events?

Platform: WinForms |
Control: Diagram

What are my options for creating a custom symbol? How do I make it respond to mouse events?

The symbol can be defined using the Essential Diagram SymbolDesigner utility, in which case, the various drawing tools in the designer may be used for creating the shapes that will make up the symbol. Symbols built using the SymbolDesigner are saved as symbol palette files and loaded into an application using symbol palettes from which it can be dragged and dropped onto the diagram as shown in the ‘Diagram\Samples\In Depth\DiagramBuilder’ sample, or used directly through the Syncfusion.Windows.Forms.Diagram.SymbolPalette API for creating instances of the symbol. The ‘Samples\Quick Start\Text Symbols\Multiline’ sample shows similar symbols designed using the SymbolDesigner utility.

The entire symbol may also be defined using the Essential Diagram API. This approach involves defining a subclass of the Syncfusion.Windows.Forms.Diagram.Symbol class in your application (or in a library module), and creating and adding the above listed nodes as children of this symbol class. The ‘Samples\Quick Start\DynamicSymbol’ sample shows a programmatically defined symbol, and referring to this implementation will give a good idea on how to go about creating the symbol.

As for responding to mouse events - highlighting a section of the symbol when it is clicked on for instance - this is especially easy to do when defining the symbol programmatically. All that you have to do is override the custom Symbol’s OnClick method, check whether one of the text rectangles was clicked by examining the method’s NodeMouseEventArgs param, and if so provide a suitable highlight for the node by changing its FillStyle or any of the other style properties. In fact, the custom symbol used by the ‘Quick Start\DynamicSymbol’ sample shows node highlighting in response to mouse click events.

Mouse events may be handled for symbols defined using the SymbolDesigner as well. This is done by either sub-classing the symbol as shown in the ‘Samples\Quick Start\CustomSymbol’ sample, and providing an override for the symbol’s OnClick method, or by simply handling the Diagram.NodeClick event in your application, and determining whether one of the text rectangles in the symbol was clicked on, and if so, change the node’s FillStyle property to reflect the clicked state.

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile