I have a treeview with a Root, a Contact Type, and a Contact. Like MSN
Messenger.
Is there a way that I can say something like
if treenode.tag is classContact then
string Surname = treenode.tag.su rname
And somehow, each time, I create the node, I can assign the object of that
classContact to that node ?
I think the 'Tag' part of the TreeNode would be used, but not sure how... 6 3732
Yes, here is a sample as to how: http://www.eggheadcafe.com/articles/...atabinding.asp
--
2004 and 2005 Microsoft MVP C#
Robbe Morris http://www.masterado.net
Earn $$$ money answering .NET Framework
messageboard posts at EggHeadCafe.com . http://www.eggheadcafe.com/forums/merit.asp
"Craig Lister" <in********@rem ovethelisters.c o.uk> wrote in message
news:42******** *************** @news.zen.co.uk ... I have a treeview with a Root, a Contact Type, and a Contact. Like MSN Messenger.
Is there a way that I can say something like
if treenode.tag is classContact then string Surname = treenode.tag.su rname
And somehow, each time, I create the node, I can assign the object of that classContact to that node ?
I think the 'Tag' part of the TreeNode would be used, but not sure how...
Thanks.
I'm looking to assign a class object that I have created, to my treenode
though...
Something like Treeview.Select edNode.Tag = myObject..
And then later, I'd like to be able to access this objects properties via
the treenode.tag. Is this possible ?
Craig
"Robbe Morris [C# MVP]" <in**@eggheadca fe.com> wrote in message
news:%2******** **********@TK2M SFTNGP14.phx.gb l... Yes, here is a sample as to how:
http://www.eggheadcafe.com/articles/...atabinding.asp
-- 2004 and 2005 Microsoft MVP C# Robbe Morris http://www.masterado.net
Earn $$$ money answering .NET Framework messageboard posts at EggHeadCafe.com . http://www.eggheadcafe.com/forums/merit.asp "Craig Lister" <in********@rem ovethelisters.c o.uk> wrote in message news:42******** *************** @news.zen.co.uk ...I have a treeview with a Root, a Contact Type, and a Contact. Like MSN Messenger.
Is there a way that I can say something like
if treenode.tag is classContact then string Surname = treenode.tag.su rname
And somehow, each time, I create the node, I can assign the object of that classContact to that node ?
I think the 'Tag' part of the TreeNode would be used, but not sure how...
Yes,
myObjectType myObject = new myObjectType( ...);
....
treeView.Select edNode.Tag = myObject;
....
((myObjectType) treeView.Select edNode.Tag).MyO bjectProperty = newValue;
....
HTH
Alex
"Craig Lister" <in********@rem ovethelisters.c o.uk> wrote in message
news:42******** *************** @news.zen.co.uk ... Thanks.
I'm looking to assign a class object that I have created, to my treenode though...
Something like Treeview.Select edNode.Tag = myObject..
And then later, I'd like to be able to access this objects properties via the treenode.tag. Is this possible ?
Craig "Robbe Morris [C# MVP]" <in**@eggheadca fe.com> wrote in message news:%2******** **********@TK2M SFTNGP14.phx.gb l... Yes, here is a sample as to how:
http://www.eggheadcafe.com/articles/...atabinding.asp
-- 2004 and 2005 Microsoft MVP C# Robbe Morris http://www.masterado.net
Earn $$$ money answering .NET Framework messageboard posts at EggHeadCafe.com . http://www.eggheadcafe.com/forums/merit.asp "Craig Lister" <in********@rem ovethelisters.c o.uk> wrote in message news:42******** *************** @news.zen.co.uk ...I have a treeview with a Root, a Contact Type, and a Contact. Like MSN Messenger.
Is there a way that I can say something like
if treenode.tag is classContact then string Surname = treenode.tag.su rname
And somehow, each time, I create the node, I can assign the object of that classContact to that node ?
I think the 'Tag' part of the TreeNode would be used, but not sure
how...
Right. That code sample does it with a DataRow. You could
just as easily do it with your class instead.
--
2004 and 2005 Microsoft MVP C#
Robbe Morris http://www.masterado.net
Earn $$$ money answering .NET Framework
messageboard posts at EggHeadCafe.com . http://www.eggheadcafe.com/forums/merit.asp
"Craig Lister" <in********@rem ovethelisters.c o.uk> wrote in message
news:42******** *************** @news.zen.co.uk ... Thanks.
I'm looking to assign a class object that I have created, to my treenode though...
Something like Treeview.Select edNode.Tag = myObject..
And then later, I'd like to be able to access this objects properties via the treenode.tag. Is this possible ?
Craig "Robbe Morris [C# MVP]" <in**@eggheadca fe.com> wrote in message news:%2******** **********@TK2M SFTNGP14.phx.gb l... Yes, here is a sample as to how:
http://www.eggheadcafe.com/articles/...atabinding.asp
-- 2004 and 2005 Microsoft MVP C# Robbe Morris http://www.masterado.net
Earn $$$ money answering .NET Framework messageboard posts at EggHeadCafe.com . http://www.eggheadcafe.com/forums/merit.asp "Craig Lister" <in********@rem ovethelisters.c o.uk> wrote in message news:42******** *************** @news.zen.co.uk ...I have a treeview with a Root, a Contact Type, and a Contact. Like MSN Messenger.
Is there a way that I can say something like
if treenode.tag is classContact then string Surname = treenode.tag.su rname
And somehow, each time, I create the node, I can assign the object of that classContact to that node ?
I think the 'Tag' part of the TreeNode would be used, but not sure how...
Thanks for the reply..
Getting an error:
Unable to cast object of type 'System.Int32' to type
'Address_Book_o n_Steroids.clas sContact'.
on the following line:
MessageBox.Show (((classContact )tvMaster.Selec tedNode.Tag).Ti tle);
Where
tvMaster is the TreeView
"AlexS" <sa***********@ SPAMsympaticoPL EASE.ca> wrote in message
news:OF******** *****@TK2MSFTNG P09.phx.gbl... Yes,
myObjectType myObject = new myObjectType( ...); ... treeView.Select edNode.Tag = myObject; ... ((myObjectType) treeView.Select edNode.Tag).MyO bjectProperty = newValue; ... HTH Alex "Craig Lister" <in********@rem ovethelisters.c o.uk> wrote in message news:42******** *************** @news.zen.co.uk ... Thanks.
I'm looking to assign a class object that I have created, to my treenode though...
Something like Treeview.Select edNode.Tag = myObject..
And then later, I'd like to be able to access this objects properties via the treenode.tag. Is this possible ?
Craig "Robbe Morris [C# MVP]" <in**@eggheadca fe.com> wrote in message news:%2******** **********@TK2M SFTNGP14.phx.gb l... > Yes, here is a sample as to how: > > http://www.eggheadcafe.com/articles/...atabinding.asp > > -- > 2004 and 2005 Microsoft MVP C# > Robbe Morris > http://www.masterado.net > > Earn $$$ money answering .NET Framework > messageboard posts at EggHeadCafe.com . > http://www.eggheadcafe.com/forums/merit.asp > > > > "Craig Lister" <in********@rem ovethelisters.c o.uk> wrote in message > news:42******** *************** @news.zen.co.uk ... >>I have a treeview with a Root, a Contact Type, and a Contact. Like MSN >>Messenger. >> >> Is there a way that I can say something like >> >> if treenode.tag is classContact then >> string Surname = treenode.tag.su rname >> >> And somehow, each time, I create the node, I can assign the object of >> that classContact to that node ? >> >> I think the 'Tag' part of the TreeNode would be used, but not sure how... >> > >
Hi Craig,
Your Tag contains a number (System.Int32) and trying to cast it to classContact will then fail.
Are all your tags classContact? Or are some of them different data types.
object o = tvMaster.Select edNode.Tag
if(o is classContact)
{
classContact c = (classContact)o ;
MessageBox.Show (c.Title);
}
On Sun, 24 Jul 2005 17:26:05 +0200, Craig Lister <in********@rem ovethelisters.c o.uk> wrote: Thanks for the reply..
Getting an error: Unable to cast object of type 'System.Int32' to type 'Address_Book_o n_Steroids.clas sContact'.
on the following line:
MessageBox.Show (((classContact )tvMaster.Selec tedNode.Tag).Ti tle); Where tvMaster is the TreeView "AlexS" <sa***********@ SPAMsympaticoPL EASE.ca> wrote in message news:OF******** *****@TK2MSFTNG P09.phx.gbl... Yes,
myObjectType myObject = new myObjectType( ...); ... treeView.Select edNode.Tag = myObject; ... ((myObjectType) treeView.Select edNode.Tag).MyO bjectProperty = newValue; ... HTH Alex "Craig Lister" <in********@rem ovethelisters.c o.uk> wrote in message news:42******** *************** @news.zen.co.uk ... Thanks.
I'm looking to assign a class object that I have created, to my treenode though...
Something like Treeview.Select edNode.Tag = myObject..
And then later, I'd like to be able to access this objects properties via the treenode.tag. Is this possible ?
Craig "Robbe Morris [C# MVP]" <in**@eggheadca fe.com> wrote in message news:%2******** **********@TK2M SFTNGP14.phx.gb l... > Yes, here is a sample as to how: > > http://www.eggheadcafe.com/articles/...atabinding.asp > > -- > 2004 and 2005 Microsoft MVP C# > Robbe Morris > http://www.masterado.net > > Earn $$$ money answering .NET Framework > messageboard posts at EggHeadCafe.com . > http://www.eggheadcafe.com/forums/merit.asp > > > > "Craig Lister" <in********@rem ovethelisters.c o.uk> wrote in message > news:42******** *************** @news.zen.co.uk ... >>I have a treeview with a Root, a Contact Type, and a Contact. Like MSN >>Messenger. >> >> Is there a way that I can say something like >> >> if treenode.tag is classContact then >> string Surname = treenode.tag.su rname >> >> And somehow, each time, I create the node, I can assign the object of >> that classContact to that node ? >> >> I think the 'Tag' part of the TreeNode would be used, but not sure how... >> > >
--
Happy coding!
Morten Wennevik [C# MVP] This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: PeteCresswell |
last post by:
I've got a routine that loads a tree control.
Works a-ok the first time around, then bombs the second. Works the
third, bombs on the fourth....i.e. it works every other time it is
invoked.
Error# always the same: -2214 741 7848, but the message varies between
"Method 'Add' of object INodes failed." and "The object invoked has
disconnected from it's clients." The first one is more common.
|
by: pei_world |
last post by:
I wrote a class inherit from TreeNode of the system as follow, but when I
try to use it with TreeView object, then it doesn't work, can anyone help?
//============== code to use the inherited node
ServiceServer.InheritTreeNode rootNode = null;
rootNode = treeServices.Nodes.Add(System.Net.Dns.GetHostName());
//*** Error: Cannot implicitly convert type 'System.Windows.Forms.TreeNode'
to 'ServiceServer.InheritTreeNode'
|
by: Sérgio Almeida |
last post by:
greetings
how can i check if a treeview contains a treenode with a specified text?
i'm trying with the Nodes.Contains() method but doesn't work. Any ideas?
Thanks
Almeida
|
by: Craig Lister |
last post by:
I have a treeview with a Root, a Contact Type, and a Contact. Like MSN
Messenger.
Is there a way that I can say something like
if treenode.tag is classContact then
string Surname = treenode.tag.surname
And somehow, each time, I create the node, I can assign the object of that
classContact to that node ?
|
by: rickpayne |
last post by:
I've noticed the IE treeview asp.net web control has a heavey viewstate. I
have been trying to use session variables to store its state instead of
storing it in viewstate. Has anyone successful used session state to store
state info?
| |
by: Slava ilyin |
last post by:
Hi!
Does anyone know how to get TreeNode RECT using VB.NET?
My code is below seems to be incorrected.
What is wrong?
(sorry, I'm a novice in .NET)
\\\
Private Declare Function SendMessage Lib "user32.dll" Alias
|
by: Luqman |
last post by:
I have used menu control of VB.net 2005, and its opening like this :-
Menu1>SubMenu1>SubSubMenu1
While I need this to display in a Hierarchy :-
Menu1
SubMenu1
SubSubMenu1
|
by: Don |
last post by:
I've created a small test class to extend the Treenode object and am
having mixed success.
In the Treeview's 'BeforeExpand' event I've used code from the help
topic "Adding Custom Information to a TreeView or ListView Control"
I've been able to add nodes of myTreeNode type to the treeview and
verify that they really are myTreeNode nodes but haven't been able to
get this part figured out.
|
by: d_mike_2004 |
last post by:
Hi,
i have been trying to add a treenode into a Treeview.
for example, say i have a tree as beloew:
Node1
Node2
Node3
Node4
Node5
Node6
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |