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
close icon

Add Symbols and Links programmatically.

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

5 Replies

ME Marco Ensing 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


ME Marco Ensing 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


NI Nikolaj Ivancic 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 :-)


JS jss 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?


AD Administrator Syncfusion Team 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

Loader.
Live Chat Icon For mobile
Up arrow icon