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

How do you add a symbol from the palette via code

Thread ID:





74657 Jun 24,2008 08:47 AM UTC Jul 3,2008 12:45 PM UTC WinForms 7
Tags: Diagram
Peter Mcintosh
Asked On June 24, 2008 08:47 AM UTC

Please can you tell me how to add a symbol from the palette via code.

Ultimately, i want to populate a context menu (via right click mouse button) with each of the items from the palette and allow the user to add nodes from this.

The Help contains the following which i guess must be out of date:


//New InsertNodesCmd
InsertNodesCmd insCmd = new InsertNodesCmd();

//Select the Symbol from the PaletteGroupView
SymbolModel symModel = this.paletteGroupView1.SelectedSymbolModel;

//New NodeCollection
NodeCollection nodes = new NodeCollection();

//Add Symbol to the NodeCollection
if (symModel != null)
Symbol triangle = symModel.CreateSymbol();

insCmd.Location = new PointF(125,125);
//ExecuteCommand to add the Symbol

J.Nagarajan [Syncfusion]
Replied On June 24, 2008 12:44 PM UTC

Hi ,

Thanks for your interest in Syncfusion products.

Please refer to the attached sample that demonstrates to load the nodes from the palette in v6.2. This sample also illustrates to show the context menu on the selected nodes in PaletteGroupViewItems. When you click on "Add new item", you can add a node in the symbol palette.


Please refer to it and let me know if this helps.


Peter Mcintosh
Replied On June 25, 2008 03:52 PM UTC

Thanks for the reply. I am not sure if this is what I am looking for. I cannot test your solution as I only have the v6.3 libraries. Please can you include the required dll's in the source. Thanks again.

Justin Kim
Replied On June 26, 2008 02:10 AM UTC

I have a similar issue. I have downloaded the sample you provided (which didn't compile with 6.2 libraries for some reason - missing PageScale class?) and it helped, but I still have outstanding questions:

In the previous version of our product, using Syncfusion 4.4, we provided a way for the users to create pre-defined symbols to the diagram through tool bar buttons. This was done through InsertSymbolTool, and bypassed the PalletGroupView (which is deemed too 'heavy' for our application. It takes a large space on screen and we'd like to avoid having to introduce a whole new UI element)

In the 6.2 version, however, I see no InsertSymbol tool or similar. Can you shed some light on this issue?


J.Nagarajan [Syncfusion]
Replied On June 26, 2008 12:19 PM UTC

Hi Justin ,

InsertNodeTool is removed in v6.2. However you can work around this problem. You have to create custom node and handle MouseUp event of the diagram control. In the MouseUp event you can insert the custom node into the model. Please refer to the attached sample for more detials.


In this sample when you click on Insert->InsertNode menuitem and mouse up the diagram control, the custom node will be inserted.

Please let me know if this helps.


Administrator [Syncfusion]
Replied On June 26, 2008 12:55 PM UTC

Hi Mcinp ,

Please refer to the modified sample that works fine in v6.3.0.6.


This sample illustrates to show the context menu on the selected nodes in PaletteGroupViewItems. When you click on "Add new item", you can add a node in the symbol palette.

Please let me know if this helps.


Peter Mcintosh
Replied On June 30, 2008 10:07 AM UTC

Thank Nagaraj. However, that was not what i was looking for. I was wanting to populate the diagrams context menu with each of the palette items so as i could add items to the diagram from the context menu.

The help (which was included in v6.3) stated that i could use "InsertNodesCmd" class as well as method "this.diagram1.Controller.ExecuteCommand()". I assume this is out of date?

I managed to get a working example by looping through each of the palettes:

//Iterate through the palettes and add menu items for each node found.
foreach (GroupBarItem item in this.symbolPaletteGroupBar.GroupBarItems) {
if (item.Client is PaletteGroupView) {
PaletteGroupView view = item.Client as PaletteGroupView;
foreach (Node n in view.Palette.Nodes) {

I stored the palette node in the Tag of the context menu item. When the user clicked on a context menu item, i called the following method:

/// Adds a node to the diagram.

private void InsertNode(Node node) {
Node newNode = (Node)node.Clone();

//We want to insert node onto diagram at mouse location
newNode.PinPoint = diagram.Controller.MouseLocation;

//Add node to diagram

I hope someone may find this usefull.

J.Nagarajan [Syncfusion]
Replied On July 3, 2008 12:45 PM UTC

Hi Mcinp ,

Thanks for the code snippet for resolving this issue. InsertNodeCmd and Controller.ExecuteCommand() are no longer valid in v6.3.0.6. You can use Model.AppendChild() method to insert a node. Please refer to the following code snippet.

Rectangle m_rectangle1 = new Rectangle(60, 70, 120, 74);

Please let me know if you have any other questions.



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