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

Dynamically Change the Custom Symbols Colour

Hello, I read that a a custom symbols colour could be changed dynamically. This would be ideal for me, as I would like to colour my symbol depending on its state. I read this in a previous message in this forum: "if you want to change a non-default value for one of the symbol''''s child nodes, then you will have to do this by directly the child node and applying the new property value directly to it". How do I change the colour of say the inner ellipse in Syncfusions custom symbols example? I would be grateful if somebody could post some code describing how this can be achieved. Thank you. David

4 Replies

AD Administrator Syncfusion Team December 23, 2005 06:14 PM UTC

David, If your custom symbol is a programmatically defined type then you should be able to directly change the inner node''s color from within your symbol class defintion. This approach is demonstrated in the DynamicSymbol sample that ships with the product. For symbols defined with the SymbolDesigner, you will have to provide an easily identifiable name for the symbol''s child nodes (through the Node.Name property), and then use the Symbol class methods to retrieve the child node. The Symbol.GetChildByName(string) method will help you with this. Once you have the child node you can set the Node''s FillStyle property to change the forecolor, backcolor etc. Prakash Surendra Syncfusion Inc.,


DL David Llewellyn December 23, 2005 10:54 PM UTC

Hello Prakash, Thank you for the information. I''m still unsure how to change the FillStyle property of an INode object. I have created a symbol using the SymbolDesigner and can retrieve the Node that I wish to change colour. For example I have done this: Symbol selectedSymbol = node as Symbol; INode tmpNode = selectedSymbol.GetChildByName("TestNode"); But how do access "tmpNode"''s FillStyle property. The fillstyle property does not exist in the INode class. The tmpNode only has the following properties: FullName, Name, Parent, Root. Thanks, David. >David, > >If your custom symbol is a programmatically defined type then you should be able to directly change the inner node''s color from within your symbol class defintion. This approach is demonstrated in the DynamicSymbol sample that ships with the product. > >For symbols defined with the SymbolDesigner, you will have to provide an easily identifiable name for the symbol''s child nodes (through the Node.Name property), and then use the Symbol class methods to retrieve the child node. The Symbol.GetChildByName(string) method will help you with this. Once you have the child node you can set the Node''s FillStyle property to change the forecolor, backcolor etc. > >Prakash Surendra >Syncfusion Inc.,


DL David Llewellyn December 24, 2005 12:59 AM UTC

Hello again, I have also tried to change the colour of all the nodes, just as a test by doing the following: foreach (INode node in this.diagram1.Model.Nodes) { Symbol selectedSymbol = node as Symbol; if (selectedSymbol != null) { selectedSymbol.FillStyle.GradientStartColor = Color.RoyalBlue; selectedSymbol.FillStyle.Color = Color.RoyalBlue; } } This doesn''t change the colour of any of the symbols I have added to my diagram (I only have one custom Symbols, which I wish to colour differently). Can somebody tell me what I am doing wrong here? Thank you and regards. David


AD Administrator Syncfusion Team December 27, 2005 10:15 PM UTC

David, It is possible that you have set a non-default value for the symbol''s child nodes. Please refer to this forum post for an explanation of how child node property values affect the propagation of symbol properties - http://www.syncfusion.com/Support/forums/message.aspx?MessageID=38140. I hope this helps. If not please let me know. Prakash Surendra Syncfusion Inc.,

Loader.
Live Chat Icon For mobile
Up arrow icon