473,386 Members | 1,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Extending the treeview control

Article 311318, "HOW TO: Create a Key Property for a
TreeView Node in Visual Basic .NET". Explains how to
extend the treeview (and treenode) classes to include a
node Key. However, to obtain a node reference, you must
still either use the index, or use a for each ... next
loop in you code to get it by key. I would like to use
the node's key or index interchangeably. To do this, I
think I need to change the treeview's Nodes property from
type TreeNodeCollection to a user defined type
TreeNodeExCollection, inheriting everything from
TreeNodeCollection but the item property. How do I do
this?

When I try, I am forced to write my own New sub, and am
not allowed to access MyBase.New(owner as treenode),
because it is private.
Nov 20 '05 #1
2 1560
Yep - as far as I know you can not inherit from the TreeNodeCollection
class since the constructor is private. Therefore, I believe this
makes the class sealed (non-derivable).

My suggestion is that you create a new class that implements the IList
interface. However, there are some things that make this very
difficult and icky, (see my post on the C# board at
http://www.dotnetboards.com/viewtopic.php?t=16350)

If you found any way round this private constructor then please let me
know.
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 20 '05 #2
This is the way I got around the problem (In C#). I'm not thrilled
that it's the best solution, but it does work...

public class ICNodeCollection
{
private TreeNodeCollection nodes;

public ICNodeCollection(TreeNodeCollection treeNodes)
{
nodes = treeNodes;
}
.... (add special functions for NodeCollection class)
}

public class ICTreeNode : System.Windows.Forms.TreeNode
{
private ICNodeCollection nodes;

public ICTreeNode() : base()
{
nodes = new ICNodeCollection(base.Nodes);
}

....
}

public class ICTreeView : System.Windows.Forms.TreeView
{
private ICNodeCollection nodes;

public ICTreeView() : base()
{
nodes = new ICNodeCollection(base.Nodes);
InitializeTreeView();
}
...
}
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Michael C | last post by:
Question about extending a class. I extended the TreeNode class, like this: class ExtendedTreeNode : TreeNode { public int value1; public int value2; public int NodeLevel() { //This...
0
by: Ismail Mayat | last post by:
Hello, I want to extend treeview control so that you can have simple binding like combobox so you can have DisplayMember and ValueMember, anyone any ideas or code on how to do this. Thanks in...
5
by: SoKool | last post by:
Can anyone point me to a site where I can get a free treeview control to use in ASP .NET or any tutorial that can help me build my own treeview control. I intend to use a treeview to generate a...
8
by: Hrvoje Voda | last post by:
What is wrong in this code? private void tree_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { if (e.KeyCode == Keys.Enter ) {
3
by: Peter | last post by:
Hello, We are inserting a side menu to our application using a class that is writing HTML on all our pages. This is a part of the code as an example: writer.Write(" <table WIDTH=""100%""...
1
by: musosdev | last post by:
Hi guys I was using the Microsoft.Web.UI.WebControls extra namespace in my application to provide me with a TreeView control. I was using specifically ..GetNodeFromIndex(), SelectedNodeIndex and...
5
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...
0
by: abramson.uri | last post by:
hi! ive implemented multiple node selection in a tree view - derived class. all goes well untill i open a file dialog through the nodes context menu and somehow, the multiple selection...
0
by: =?Utf-8?B?TWFydGluIEVtYW51ZWxzc29u?= | last post by:
Hello, I have a case where we'd like to add a textbox next to each leaf of a TreeView. Has anyone here tried doing this or does anyone know if it's at all possible? Any input is appreciated....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.