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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Polygon Tool

Thread ID:





67863 Sep 1,2007 09:24 AM UTC Sep 6,2007 08:52 PM UTC WinForms 3
Tags: Diagram
Asked On September 1, 2007 09:24 AM UTC

I am using the polygon tools and i have a few questions:

1 -How can i change the color of the drawed polygon, by default it is yellow, i want it to be transparent.

2- How can i control the insert node event and delete node event.. for example when a polygon is inserted i want to change it's default name and when a polygone is deleted i want some code to be executed.

3- On doubleclicking a node, i want this node to be the selected node and also execute some code.

Thank you for you quick reply


J.Nagarajan [Syncfusion]
Replied On September 3, 2007 08:44 PM UTC

Hi Elie,

Thanks for your continued interest in Syncfusion product.

1. To change the color of polygon, you have to derive PolygonTool class and override the CreateNode() method. Please refer to the following code snippet

public class MyPolygonTool: PolyLineBase
protected override Node CreateNode( PointF[] pts )
Polygon m_polygon = new Polygon(pts);
m_polygon.FillStyle.Color = Color.Transparent;
return (m_polygon);

// In Tool->Polygon menuitem's click event
private void menuItem2_Click(object sender, EventArgs e)
MyPolygonTool m_polygon = new MyPolygonTool(this.diagram1.Controller);

I have attached the sample that demonstrates this completely. You can download the sample from the following page.

2. To change the node's name when it inserts into the diagram model then you have to handle EventSink.NodeCollectionChanged event. In this event you can add your code when you delete the selected node. Please refer to the following code snippet

this.diagram1.Model.EventSink.NodeCollectionChanged+=new CollectionExEventHandler(EventSink_NodeCollectionChanged);

private void EventSink_NodeCollectionChanged(CollectionExEventArgs evtArgs)
// Control InsertNodeevent
if (evtArgs.ChangeType == CollectionExChangeType.Insert)
Node objnode = evtArgs.Element as Node;
objnode.Name = "PolygonNode";

if (evtArgs.ChangeType == CollectionExChangeType.Remove)
Console.WriteLine("Removed the node from the Diagram");

Sample: http://websamples.syncfusion.com/samples/Diagram.Windows/F67863/main.htm

3. To achieve this you have to customize a node and you can perform the MouseDoubleClick event. Please refer to the following code snippet.

public class MySymbol : Group
protected override void OnMouseDoubleClick()
if (this.m_curEllipseColor == m_ellipseColors.Length - 1)
this.m_curEllipseColor = 0;
this.m_innerEllipse.FillStyle.Color = m_ellipseColors[this.m_curEllipseColor];

MessageBox.Show("NodeDoubleClick event gets fired");

I have attached the sample that demonstrates this completely. You can download the sample from the following page


Please refer to the sample and let me know if you have any questions.


Replied On September 4, 2007 06:55 AM UTC

Thank you for your reply,
this was just the event that i needed.

J.Nagarajan [Syncfusion]
Replied On September 6, 2007 08:52 PM UTC

Hi Elie,

Thanks for the update.

Please feel free to contact us if you have any other questions.

Thansk for your continued interest in Syncfusion product.



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

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

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