Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Select object by code vb.net (Read 2123 times)
dzapata2007
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 3
Joined: May 19th, 2009
Select object by code vb.net
May 19th, 2009 at 8:46pm
Print Post  
Excuse me, i'm new in using this software.

How can I make vb.net code to search a node, and once found to change image and text through code? could give an example
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Select object by code vb.net
Reply #1 - May 20th, 2009 at 5:28am
Print Post  
If you assign some Tag values to nodes, you could use the FindNode method to find a node:

Code
Select All
Dim n As ShapeNode
n = Diagram1.FindNode(1)
If n IsNot Nothing Then
	n.Image = Image.FromFile("image.png")
	n.Text = "new label"
End If
 



If you need to search for nodes by some other criteria, do a for-each loop over diagram.Nodes and check if the node meets the condition.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
dzapata2007
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 3
Joined: May 19th, 2009
Re: Select object by code vb.net
Reply #2 - May 20th, 2009 at 3:18pm
Print Post  
Dear Stoy,

When you run the example I gave (with the considerations of the case in relation to the Tag of the nodes) the problem I have is that Visual Basic 2008, you sent me the following error:

"Unable to cast object of type 'MindFusion.Diagramming.WinForms.Samples.VB.IconNodes.IconNode' to type 'MindFusion.Diagramming.ShapeNode."

FindNode () returns an object IconNode rather ShapeNode, with which I do not have access to the properties of the found object.

Thanks for your great and fast support.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Select object by code vb.net
Reply #3 - May 20th, 2009 at 3:39pm
Print Post  
If you are going to use only IconNodes, just define Dim n As IconNode. Otherwise use the TypeOf .. Is operator to check the type of the returned node, and then CType it to the correct type to use the appropriate properties.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
dzapata2007
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 3
Joined: May 19th, 2009
Re: Select object by code vb.net
Reply #4 - May 20th, 2009 at 3:44pm
Print Post  
Dear Stoyo,

We apologize for the inconvenience, was the simple fix, just change the line defining the variable "n":

Dim n as IconNode

And everything worked properly.

Thanks for your support.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint