Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic netdiagram newbie (Read 1708 times)
way77
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 1
Joined: Feb 13th, 2008
netdiagram newbie
Feb 13th, 2008 at 2:22am
Print Post  
Hi,
  I'm drawing the  nodes  from the database. The nodes have its own number. There will be many nodes inside FlowChart and they are cross-linked. If there is a repeated node (same number), it won't be draw twice in the FlowChart.
  I also would like to find a specific node in the FlowChart and then link it with other node. Can it be done in coding?

Please help. Thanks.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: netdiagram newbie
Reply #1 - Feb 13th, 2008 at 6:47am
Print Post  
Hi,

Say you have the two tables to keep the node data and their many-to-many relations:

Nodes
--------
id: int
text: text

Links
--------
id: int
origin: int
dest: int

Then you can read the database data and create the corresponding flowchart items like that:

Code
Select All
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "SELECT * FROM dbo.Nodes";
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
	Box node = fc.CreateBox(0, 0, 40, 30);
	node.Tag = reader.GetInt32(0);
	node.Text = reader.GetString(1);
}
reader.Close();

cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "SELECT * FROM dbo.Links";
reader = cmd.ExecuteReader();
while (reader.Read())
{
	fc.CreateArrow(
		fc.FindBox(reader.GetInt32(1)),
		fc.FindBox(reader.GetInt32(2)));
}

AnnealLayout al = new AnnealLayout();
al.Arrange(fc);
 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint