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

Add Symbols and Links programmatically.

Thread ID:





11156 Feb 25,2004 08:52 AM UTC Apr 16,2004 04:50 PM UTC WinForms 5
Tags: Diagram
Asked On February 25, 2004 08:52 AM UTC

Does somebody have an example of how to add symbols programmatically, and add links between them.

Marco Ensing
Replied On March 31, 2004 08:19 PM UTC

I actually would love to know this as well. I''ve been trying with trial and error and it seems that the model does take an insertChild. But I don''t know how to create my own INode childeren, and what the index is representing Marco

Marco Ensing
Replied On April 2, 2004 07:33 PM UTC

I got something working, don''t know if it is the most efficient way. But it''s a start. PointF[] line = new PointF[]{ new PointF(e.Source.x, e.Source.y), new PointF(e.Target.x, e.Target.y)}; LinkCmd lc = new LinkCmd (MySymbolSource.CenterPort, MySymbolTarget.CenterPort, line); lc.Do(this.model.Root); If anybody has recommendations let me know. I still wonder if there is a difference to which parent node I put my created INodes? Is there a performance difference? If not, why do I have to specify it? and why would I not just say, put this line on this model where Syncfusion would wrap this around and put it at the Root. I''m sure I''m missunderstanding things here. But correct me where I go wrong. Regards, L.A.Marco

Nikolaj Ivancic
Replied On April 4, 2004 10:59 PM UTC

The Diagram''s OrgChart sample has all that you need - and more. I used it to get the answers to the same set of questions you are asking :-)

Replied On April 15, 2004 03:05 PM UTC

The OrgChart example only shows how to implement the tools required to enable the user to interactively add symbols and links. What I would like to know is how to add symbols and links ''non-interactively''. (entirely through code) Has anyone figured that out? If so, where can I find an example?

Administrator [Syncfusion]
Replied On April 16, 2004 04:50 PM UTC

Hi, Adding a Symbol programmatically is very similar to using the interactive insert tools. In place of the Insert tool, create an instance of the Syncfusion.Windows.Forms.Diagram.InsertNodesCmd command type, initialize it with the Symbol, the insert layer & location and use the Diagram''s Controller.ExecuteCommand(Syncfusion.Windows.Forms.Diagram.ICommand) method to add the Symbol to the specified layer. The following code shows a simple implementation that creates an instance of the CustomSymbol class and inserts it at Point(50,50) on the Model''s Default Layer, Symbol sym = this.customSymbolMdl.CreateSymbol(); if (sym != null) { // Create the InsertNodes Command Diagram.InsertNodesCmd insCmd = new Diagram.InsertNodesCmd(); // Initialize the Command object for the Symbol and set the insert layer and location insCmd.Nodes.Add(sym); insCmd.LayerName = this.diagram1.Model.DefaultLayerName; insCmd.Location = new Point(50,50); // Execute the Insert command through the Diagram''s Controller this.diagram1.Controller.ExecuteCommand(insCmd); } The Essential Diagram Class Reference documentation on the InsertNodesCmd class and the Controller.ExecuteCommand() method should provide more detailed information. Prakash Syncfusion, Inc


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