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

Node selection

Hi,

I have a couple custom nodes which draw their content themselves. Now I need to detect within the node's drawing functions whether it is selected or not. If a node gets selected it should draw its content differently and do some other things.

How can I achieve this? I couldn't find anything in the node's properties to see if it is selected/activated.

Regards,
Christian




3 Replies

AA Amsath Ali M Syncfusion Team March 8, 2012 09:14 AM UTC

Hi Christian,

Thanks for your interest in Syncfusion products.

We suggest you to use the Diagram’s ‘NodeSelected/Deselected’ event and Diagram.View’s ‘SelectionList’ property to find whether the given node is selected or not. Please refer the below code snippet to achieve your requirement.

Here is the code:
[C#]
diagram1.EventSink.NodeSelected += new Syncfusion.Windows.Forms.Diagram.NodeSelectedEventHandler(EventSink_NodeSelected);
diagram1.EventSink.NodeDeselected += new NodeSelectedEventHandler(EventSink_NodeDeselected);

void EventSink_NodeSelected(Syncfusion.Windows.Forms.Diagram.NodeSelectedEventArgs evtArgs)
{
if (diagram1.View.SelectionList[0] is CustomNode)
{
listBox1.Items.Clear();
listBox1.Items.Add("custom Node selected");
}
}

Here is the sample:
F102820-225975699.zip

Please try the above sample and let us know if you have any queries.

Regards,
Amsath Ali. M




CR Christian Rattat March 8, 2012 03:47 PM UTC

Hi,

thanks for the explanation. I saw this event before but this means to maintain the node's states and render its content based on the selection, I have to manually set a flag in each node every time it gets selected or deselected. This is quite uncomfortable and also error prone.

As you are using the MVC pattern thus this should belong in the model and be available by the view part so that the view could indicate state changes and retrieve its current state from the model as MVC defines it.

Do you plan to change this in the future (we are on version 8.2 now) or did already in a later version?

Regards,
Christian



AA Amsath Ali M Syncfusion Team March 9, 2012 12:46 PM UTC

Hi Christian,

Thanks for the update.

Currently we don’t provide support for “Need a property in node to indicate whether that node is selected or not”. This has been suspected to be a feature request. Please create a DT incident for your query so that we can update the patch for this feature.

You can create the DT incident from the following link.
http://www.syncfusion.com/account/dashboard

In the interests of maintaining confidentiality, we have a policy of not sharing patches or otherwise proprietary customer specific information in the public Forum.

Please let us know if you have any queries.

Regards,
Amsath Ali. M





Loader.
Live Chat Icon For mobile
Up arrow icon