- Home
- Forum
- ASP.NET Web Forms (Classic)
- How To Change Name for Node
How To Change Name for Node
- Aug 30, 2007 03:47 AM UTC
- Sep 5, 2007 09:29 PM UTC
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
{
// 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
SIGN IN To post a reply.
3 Replies
J.
J.Nagarajan
Syncfusion Team
August 31, 2007 02:54 AM UTC
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
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
CU
cuongnq
September 5, 2007 12:49 PM UTC
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
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.
J.Nagarajan
Syncfusion Team
September 5, 2007 09:29 PM UTC
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
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
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
CU cuongnq
- Aug 30, 2007 03:47 AM UTC
- Sep 5, 2007 09:29 PM UTC