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.
Unfortunately, activation email could not send to your email. Please try again.

Diagram - Select Node

Thread ID:

Created:

Updated:

Platform:

Replies:

99686 Jun 5,2011 06:03 AM Jul 26,2011 01:14 PM Windows Forms 6
loading
Tags: Diagram
Ahm user
Asked On June 5, 2011 06:03 AM

Hi,

I have been trying to use the Windows Forms - Diagram features of you products.

I find that the documentation needs some work for a novice like myself using your controls to get started.

Nevertheless, I have been able to get started albeit with a fair amount of work was able to get started.

My issue is this:
I have a standard winforms button control on my form which when I click must change a particular node's (rectangle or polygon) colour and line width. I know the name of the node that needs to have the colour changed.

My second issue is:
How do iterate through all the nodes so that all nodes have a blue colour or a transparent colour.


Hope someone can help as they seem to be easy issues to solve - I just cannot find the documentation for this.




Amsath Ali M [Syncfusion]
Replied On June 6, 2011 04:50 AM

Hi Ahm,

Thanks for using Syncfusion products.

We suggest you to use the Node’d ‘Fillstyle.Color’ and ‘LineStyle.LineWidth’ property to change the clor and linewidth of a node respectively.
Please refer the below code snippet:

[C#]

Syncfusion.Windows.Forms.Diagram.Rectangle rect = new Syncfusion.Windows.Forms.Diagram.Rectangle(100, 100, 75, 50);
rect.FillStyle.Color = Color.Blue;
rect. LineStyle.LineWidth = 2;

To iterate through all the nodes in diagram control on the button click, we suggest you to use the following code snippet:

[C#]

NodeCollection nodes = this.diagram1.Model.Nodes;

foreach(FilledPath node in nodes)
{
if (node.Name == "Rectangle")
{
node.FillStyle.Color = Color.Yellow;
node.LineStyle.LineWidth = 2;
}
}

For your convenience, we have created a simple sample to achieve your requirement.
Please try the below sample and let us know if you have any queries.
forum changing fllstyl on btnclk782123536.zip

Regards,
Amsath Ali. M



Ahm user
Replied On June 6, 2011 09:25 AM

Thanks for your answer.

I had a look at the attached app.

My problem is that I know the name of the node (I do not know the shape and type of node) and I want to change the fillstyle.

Hope you can assist further.

Many thanks



Ahm user
Replied On June 6, 2011 01:34 PM

I got the procedure partially working in VB.NET.

I used the following:

'For all nodes
Dim nodes As NodeCollection = Me.Diagram1.Model.Nodes

For Each node As FilledPath In nodes
node.FillStyle.Color = Color.Yellow
node.FillStyle.ColorAlphaFactor = 255
node.LineStyle.LineWidth = 0
Next


'For a particular node
Dim nodes As NodeCollection = Me.Diagram1.Model.Nodes

For Each node As FilledPath In nodes
If node.Name = "Rectangle1" Then
node.FillStyle.Color = Color.Yellow
node.FillStyle.ColorAlphaFactor = 255
node.LineStyle.LineWidth = 0
End If
Next

The problem is that I have a bitmap on my diagram and therefore get the following error:

Unable to cast object of type 'Syncfusion.Windows.Forms.Diagram.BitmapNode' to type 'Syncfusion.Windows.Forms.Diagram.FilledPath'.


I also find that one has to iterate through all nodes just to select change the setting of one node - there has to be an easier way.



Amsath Ali M [Syncfusion]
Replied On June 9, 2011 04:54 AM

Hi Ahm,

Thanks for the update.

We suggest you to use the below code snippet to iterate through all the nodes in diagram control and change the fillstyle of particular node.
Please refer the below code snippet:
Dim nodes As NodeCollection = Me.diagram1.Model.Nodes
For Each node As Node In nodes
If TypeOf node Is FilledPath Then
If node.Name = "Rectangle" Then
Dim fnode As FilledPath = CType(node, FilledPath)
fnode.FillStyle.Color = Color.Aqua
node.LineStyle.LineWidth = 2
End If
If node.Name = "Ellipse" Then
Dim fnode As FilledPath = CType(node, FilledPath)
fnode.FillStyle.Color = Color.LightPink
End If
End If
Next node
For your convenience, we have created a simple sample to achieve your requirement.
Please try the below sample and let us know if you have any queries.
ChangingFillStyllinBtnClk460163111.zip

Regards,
Amsath Ali. M




RK
Replied On July 21, 2011 04:13 AM

i am using diagram control.how to get selected nodename in runtime.


Amsath Ali M [Syncfusion]
Replied On July 26, 2011 01:14 PM

Hi Rk,

Thanks for your interest in Syncfusion products.

We are glad to inform you that we have achieved your requirement.
Here is the sample:
Incident-node selected-1842278934.zip

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

Regards,
Amsath Ali. M



CONFIRMATION

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.

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.

;