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

How to programatically select (highlight in diagram) a diagram node?

Hello,
I would like to select programmatically some specific nodes in my diagram, that is, to show them as selected (highlighted, showing the handlers). Is there any way to do this?
Thanks, Colin


5 Replies

AD Administrator Syncfusion Team March 14, 2008 11:28 AM UTC

Hi Colin,

Thank you for your interest in Syncfusion Products.

By default, when selecting nodes at run time itself, it is not possible to select multiple nodes individually. When we select multiple nodes, it will be selected as like

GroupNodes. Please refer the following videoclip that illustrates this behaviour:

http://websamples.syncfusion.com/samples/Diagram.Windows/F72289/VideoClip.zip

Please let me know if any concerns.

Regards,
Fathima



CO Colin March 15, 2008 01:54 PM UTC

Hello Fathima,
Thank you for your help and your answer. However, my concern was how to PROGRAMATICALLY select -highlight / make the handlers visible- a node in a diagram (without any user input in the diagram itself; actually, the node will be selected by the users from within a list of nodes -defined by their label- elsewhere, and I would like to reflect this choice by highlighting the corresponding node in the diagram).
I was trying to find something like:
Rectangle ChosenNode = NodeChosenByTheUserInAList;
diagram1.Model.Nodes[ChosenNode.Name].Select();
But I couldn't find any such solution.
I hope this clarifies a bit my issue...
Thank you for your help,
Regards, Colin



AD Administrator Syncfusion Team March 18, 2008 08:17 AM UTC

Hi Colin,

Thank you for your update.

To select a particular node programmatically, curently we dont have any specific method. We need to add the nodes to the selection list so that the nodes will get selected. Please refer the following code snippets that illustrates this:

NodeCollection nodes = this.diagram1.Model.Nodes;
foreach (Node n in nodes)
{
if (n.Name.Equals("rec2"))
diagram1.View.SelectionList.Add(n);
}

Please find the simple sample in the following link:

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

Please let me know if any concerns.

Regards,
Fathima



CO Colin March 20, 2008 03:36 PM UTC

Hi Fathima,
I am experiencing problems to open the sample you linked... But the sample code you wrote was exactly what I was looking for!
Thanks a lot for you help with this issue!
Regards,
Colin



LE Leo March 21, 2008 03:29 PM UTC

I had a similar question with regards to selecting node programmatically. I used the provided example and it did work. The problem is that my node when I select it programmatically, become resizable even though the following properties are set to false:
EditStyle.AllowRotate = false
EditStyle.AllowChangeHeight = false
EditStyle.AllowChangeWidth = false

When the node is selected by mouse-click the resizing points of the selection are disabled.
They become enabled only when node is selected programmatically. How can I keep them disabled?

Thanks,
Leo



Loader.
Live Chat Icon For mobile
Up arrow icon