Hi,
I am trying to convert a VB.net code to C# .
it is to bind a treeview from a collection. but not finding a Collection which stores treenodes as object.
Cant use hashtable since it automatically sorts the data by key.
Can anybody tell me a collection which takes objects and doesn't sort it.
The code is as follows. can anybody convert this? -
Private Sub TreeViewPopulation(ByVal ds As DataSet, Optional ByVal intParent As Integer = 0)
-
Dim TvwParent As New TreeNode
-
-
Dim TvwNode As New TreeNode Dim CollItems As New Collection
-
Try
-
-
tvw.Nodes.Clear()
-
-
For Each dr As DataRow In ds.Tables(0).Rows ''''assigning dataset values to a collection as node
-
-
TvwNode = New TreeNode(dr("Employee_Nm").ToString)
-
TvwNode.Tag = dr("Parent")
-
-
CollItems.Add(TvwNode, dr("Employee_Id"))
-
Next
-
-
For Each TvwNode In CollItems
-
TvwParent = Nothing
-
-
'find parent of a node
-
-
If Val(TvwNode.Tag) <> intParent Then TvwParent = CType(CollItems.Item(TvwNode.Tag.ToString), TreeNode)
-
If Not TvwParent Is Nothing Then
-
-
'add child node to its parent node
-
-
CType(CollItems.Item(TvwNode.Tag.ToString), TreeNode).Nodes.Add(TvwNode.Clone)
-
Else
-
-
tvw.Nodes.Add(TvwNode) 'add node to Treeview
-
-
End If
-
-
Next
-
-
Catch ex As Exception MsgBox("TreeView Population Error", MsgBoxStyle.Critical)
-
End Try
-
-
End Sub
-
plz dont give me the online code converter
Thanks in Advance, Balu
6 1432 Plater 7,872
Recognized Expert Expert
Anything in the System.Collecti ons namespace would be fine?
Maybe:
System.Collecti ons.Generic.Lis t<TreeNode>
The functionality should be roughly the same.
Frinavale 9,735
Recognized Expert Moderator Expert
Hi Balu,
Welcome to theScripts!
In order to help answer your questions more quickly please provide a meaningful Title for any threads you start (your title should reflect the problem your having).
Check out the Posting Guidelines for a set of rules that we follow here and especially take a look at the section on Please Use Appropriate Titles for New Threads. This not only helps us to answer your question more quickly but also helps to ensure that other members, and the general public, will have a better chance of finding answers to any similar questions.
Since you're posting in the .NET forum I also recommend you check out the stick post about how to Get a Faster Answer To Your Question for some tips on good titles in this forum.
Thanks!
-MODERATOR Frinny
Anything in the System.Collecti ons namespace would be fine?
Maybe:
The functionality should be roughly the same.
i cant access System.Collecti ons.Generic.Lis t<TreeNode>
Anything in the System.Collecti ons namespace would be fine?
Maybe:
System.Collecti ons.Generic.Lis t<TreeNode>
The functionality should be roughly the same.
i didnt get System.Collecti ons.Generic.Lis t<TreeNode>
Frinavale 9,735
Recognized Expert Moderator Expert
You're code is not completely valid. You have a line on which you have 2 Dim statements (this is not valid in VB ...since VB doesn't use ";"'s there's no way for the compiler to know what the end of the statement is)
Have you taken a look at the TreeNode Class? It has an example on how to manipulate TreeNodes in both C# and VB.NET.
-Frinny
Plater 7,872
Recognized Expert Expert
i didnt get System.Collecti ons.Generic.Lis t<TreeNode>
Are you sure you're in .NET?
In the solution explorer, under references, there should be some namespaces listed.
Make sure that "System" is one of them.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Ian Powell |
last post by:
Hi
I've got objects in an sorted ArrayList like:
P:\
P:\\DOCS
P:\\i386
P:\\i386\ASMS
P:\\i386\ASMS\1000
P:\\i386\ASMS\1000\MSFT
|
by: Björn Bengtsson |
last post by:
Hello!
I have an urgent problem concerning ASP.NET, ADO.NET, SQL Server, XML and
the TreeView control.
I have two tables; one describing the products and one describing their
relationships. A product may consist of multiple other products. So far
everything is great. But one product may exist as a subproduct to multiple
parent products.
My tables:
|
by: Karim El Jed |
last post by:
Hi,
I'm trying to expand a special Node of my TreeView from Codebehind.
I have a TreeView on a page for navigating to another site. On the other
tsite here is the same TreeView more precisely a new TreeView with the same
nodes ;)
So I would like to keep the expanding state of the first Tree for the second
one on the next page. At least the last selected node (path will be saved in
query string) should be expanded.
|
by: Evan Kontos |
last post by:
I am trying to implement a Treeview w/an XML file and I even copied and
pasted examples from MSDN but can't get them to work. Any suggestions
welcome.
XML File
<TREENODES>
<TREENODE TEXT="Document-1">
<TREENODE TEXT="Folder-1" EXPANDED="true">
<TREENODE TEXT="Document-2" />
|
by: Jeff Beem |
last post by:
I have a class that inherits from TreeView. The treeview has tooltips for
the nodes but they're showing up behind the form. Has anyone seen this? Are
there any known fixes?
Thanks in advance,
Jeff Beem
| |
by: christof |
last post by:
I've got a really easy problem, please help me:
There are two pages in one I'm creating a TreeView like that:
TreeView dbTree = new TreeView();
TreeNode dbTreeRoot = new TreeNode("Root");
dbTree.Nodes.Add(dbTreeRoot);
..
..
|
by: William Sullivan |
last post by:
I desperately want to replace my hand-made ajax treeview with the 2.0
TreeView. The webpage I'm designing uses the postbacks to dynamically fill
the treeview. The reason why I'm doing this is because my tree is ENORMOUS.
It can possibly hold millions of nodes. The problem is keeping this treeview
constrained as a user clicks through the nodes. I've tried putting it in a
DIV with a set width and height, but the problem is that when you...
|
by: Matt MacDonald |
last post by:
Hi All,
I have a form that displays hierarchical categories in a treeview. Ok so
far so good. What I was to do is have users be able to select a node in the
treeview as part of filling out the form. I only want to allow single
selection, so using checkboxes is out of the question. It works as is, but
it makes the form very cumbersome if every time that a user selects a node,
the whole page has to reload. Is there a way to have a node...
|
by: Nikron |
last post by:
Hi,
I'm having an issue with the ASP.NET 2.0 Treeview control and persisting
its' state accross requests. My Control is embedded within a master page
and is used for site navigation. My problem is that the user wants to
know which page they are currently on and therefore I need to highlight
the selected node. The problem is I lose state whenever the user selects
a node and is redirected to another page.
Thanks in advance
|
by: bsturg21 |
last post by:
Hello,
I have an app that has a custom treeview which inherits the base
treeview class and I am having a problem with the way the treeview is
being redrawn. Each node in the treeview represents a folder, and
this problem began when I added the functionality to have a ghost
image of the folder when it is dragged and dropped to another location
in the treeview. My code to create the ghost image is as follows:
this.NodeToBeDeleted =...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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: 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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |