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.

How To Change Name for Node

Thread ID:

Created:

Updated:

Platform:

Replies:

67796 Aug 29,2007 11:47 PM Sep 5,2007 05:29 PM ASP.NET Web Forms (Classic) 3
loading
Tags: DiagramWebControl
cuongnq
Asked On August 29, 2007 11:47 PM

foreach ( EmpObj Emp in alemployees )
{
// Create a EmployeeSymbol for each employee in the organization and add the membersymbol to
// the diagram.

int x = (int)Session["X"];
int y = (int)Session["Y"];

Syncfusion.Windows.Forms.Diagram.Rectangle nodeEmp = new Syncfusion.Windows.Forms.Diagram.Rectangle(x, y, 200, 60);

can I change the Name of nodeEmp when change value in command foreach

I want nodeEmp into nodeEmp1,nodeEmp2...nodeEmpN:(N is value of foreach run)
Syncfusion.Windows.Forms.Diagram.Rectangle nodeEmp1 = new Syncfusion.Windows.Forms.Diagram.Rectangle(x, y, 200, 60);


Plz help me
Thanks

J.Nagarajan [Syncfusion]
Replied On August 30, 2007 10:54 PM

Hi Cuongnq,

Thanks for your interest in Syncfusion product.

If your intention is to set the name for the nodes then you can use node.Name property. Please refer to the following code snippet

for (int i = 0; i < 10; i++)
{
// Create a EmployeeSymbol for each employee in the organization and add the membersymbol to
// the diagram.

int x = 50 + i * 50;
int y = 60;
Rectangle m_rect1 = new Rectangle(x, y, 120, 58);
this.DiagramWebControl1.Model.AppendChild(m_rect1);

}

foreach (INode node in this.DiagramWebControl1.Model.Nodes)
{
Node m_node=node as Node;
m_node.Name = string.Format("Rect{0}", ++i);
Response.Write(m_node.Name);
}

I have attached the sample that demonstrates this completely.

CreateNodes.zip

Please refr to the sample and let me know if you have any questions.

Regards,
Nagaraj

cuongnq
Replied On September 5, 2007 08:49 AM

Thanks for reply!
When i use your code:
----------------------
foreach (INode node in this.DiagramWebControl1.Model.Nodes) { Node m_node=node as Node;
m_node.Name = string.Format("Rect{0}",++i);
Response.Write(m_node.Name);
}
----------------------
If in the diagram have a node is LineConnector(LineConnector) and I use Node.Name then

"System.NullReferenceException: Object reference not set to an instance of an object"

How i control about that?

>Hi Cuongnq,

Thanks for your interest in Syncfusion product.

If your intention is to set the name for the nodes then you can use node.Name property. Please refer to the following code snippet

for (int i = 0; i < 10; i++)
{
// Create a EmployeeSymbol for each employee in the organization and add the membersymbol to
// the diagram.

int x = 50 + i * 50;
int y = 60;
Rectangle m_rect1 = new Rectangle(x, y, 120, 58);
this.DiagramWebControl1.Model.AppendChild(m_rect1);

}

foreach (INode node in this.DiagramWebControl1.Model.Nodes)
{
Node m_node=node as Node;
m_node.Name = string.Format("Rect{0}", ++i);
Response.Write(m_node.Name);
}

I have attached the sample that demonstrates this completely.

CreateNodes.zip

Please refr to the sample and let me know if you have any questions.

Regards,
Nagaraj


J.Nagarajan [Syncfusion]
Replied On September 5, 2007 05:29 PM

Hi Cuongnq,

You can try setting the name property of the LineConnector after attached the LineConnector in a DIagram Model. Please refer to the following code snippet

NodeCollection coll = new NodeCollection();
for (int i = 0; i < 10; i++)
{
// Create a EmployeeSymbol for each employee in the organization and add the membersymbol to
// the diagram.

int x = 50 + i * 50;
int y = 60 + i * 100;
Rectangle m_rect1 = new Rectangle(x, y, 120, 58);
this.DiagramWebControl1.Model.AppendChild(m_rect1);
coll.Add(m_rect1);

}
for (int i = 0; i < 10; i++)
{
if (i + 1 < 10)
{
Node node1 = coll[i] as Node;
Node node2 = coll[i + 1] as Node;
LineConnector line = new LineConnector(node1.PinPoint, node2.PinPoint);

this.DiagramWebControl1.Model.AppendChild(line);
node1.CentralPort.TryConnect(line.HeadEndPoint);
node2.CentralPort.TryConnect(line.TailEndPoint);
}
}

foreach (INode node in this.DiagramWebControl1.Model.Nodes)
{
Node m_node=node as Node;
if(m_node is Rectangle)
{
m_node.Name = string.Format("Rect{0}", ++i);
Response.Write(m_node.Name);
}
if (m_node is LineConnector)
{
m_node.Name = string.Format("LineConnector{0}", ++j);
Response.Write(m_node.Name);
}

}

I have attached the sample that demonstrates this completely.

CreateNodes.zip

Please refer to the sample and let me know if you have any questions.

Best regards,
Nagaraj



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.

;