473,544 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Treeview Checked Count Problem

Hi,

Could I please ask if anyone could help me solve this problem in
VS2003:

I'm trying to count all the nodes that have a Checked state however
this doesn't seem to be working for me.

So here is the code:

Dim prCount As Integer 'parent checked count
Dim chCount As Integer 'child checked count
Dim tn As New TreeNode
For Each tn In Me.TreeView_db. Nodes
If tn.Tag = "Column" Then
If tn.Checked = True Then
chCount = chCount + 1
End If
ElseIf tn.Tag = "Table" Then
If tn.Checked = True Then
prCount = prCount + 1
End If
End If
Next tn

This is not giving me the right count, actually it's giving me zero
always.

Thank You,

Norton Who

Mar 4 '07 #1
2 3038
Norton,

I thought that this newsgroup was filled with recursive samples about this
problem. I saw it is not so it is a nice sample to make for our newsgroup
one of these days. (Not today anymore for that it is to late now.

Basicly you have to do it recursive. Create a method that you use to call
itself as long as that not everything is done. A treeview exist from nodes
which hold nodes etc etc.

(I give you a sample on our website from recursive, be aware this is not
about a treeview that I could not find for VB.Net).

http://www.vb-tips.com/dbpages.aspx?...f-c9d54e1a8d9e

I hope this helps something,

Cor

"Norton Who" <No********@gma il.comschreef in bericht
news:11******** **************@ c51g2000cwc.goo glegroups.com.. .
Hi,

Could I please ask if anyone could help me solve this problem in
VS2003:

I'm trying to count all the nodes that have a Checked state however
this doesn't seem to be working for me.

So here is the code:

Dim prCount As Integer 'parent checked count
Dim chCount As Integer 'child checked count
Dim tn As New TreeNode
For Each tn In Me.TreeView_db. Nodes
If tn.Tag = "Column" Then
If tn.Checked = True Then
chCount = chCount + 1
End If
ElseIf tn.Tag = "Table" Then
If tn.Checked = True Then
prCount = prCount + 1
End If
End If
Next tn

This is not giving me the right count, actually it's giving me zero
always.

Thank You,

Norton Who

Mar 4 '07 #2
Norton Who wrote:
I'm trying to count all the nodes that have a Checked state however
this doesn't seem to be working for me.

So here is the code:
.. . .
For Each tn In Me.TreeView_db. Nodes
[tree].Nodes no longer contains all the Nodes in the tree (unlike VB6).

It /only/ contains the Nodes at the /root/ level.

Every Node has its own Nodes collection, so you need to go Recursive to
retrieve them all.

HTH,
Phill W.
Mar 6 '07 #3

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

Similar topics

4
5247
by: Jeroen Ceuppens | last post by:
Hi, I want to make something that adds a TreeNode to the end of TreeView, that TreeView Looks like + Level 1 + Level 2 + Level 3 - Level last
3
821
by: feel | last post by:
Goin' crazy with this recursive function ported from delphi... I send a string like DirA/ DirB /DirC but i get in the treeView each one in a new node.Cant get the child node....!! -DirA -DirB -DirC instead of: DirA | - DirB
2
2401
by: Srinivasa Raghavan | last post by:
Hi I am using ASP Tree View Control to display data in hiearchy fashion.I am having a checkbox next to the TreeView Node.When user checks or unchecks the nodes and click a button i am putting that count in a stringcollection which is in viewstate.The count is wrong after certain checks and click of the button.can any one explain what...
1
2164
by: Srinivasa Raghavan | last post by:
Hi All, I have some doubts on the Treeview control and Form Authentication 1) will Form Authentication work if cookies are disabled. 2) I have problem in the following code (TreeView Control with checkbox)
0
4734
by: Brian Keating | last post by:
hi there i've a test program that creates a treeview and destroys it over and over, i keep track of the gdi object count for the process and see if they are ok. However when i switch on checkboxes for my test app i get a gdi handle leak anyone got any ideas on this one? using System;
3
3454
by: pamelafluente | last post by:
Hi I have some instances of a class: Class Myobject Public Color As Color Public Label As String End Class I need to show these instances on a treeview (which has checked boxes)
1
3261
by: Christian Rühl | last post by:
hey! what i wanna do sounds very simple at first, but it turned out to be a real bone crusher... i want to check if a treeView node is checked and if a correspondent node in my xml config file exists just to sort of synchronize them by changing the xml nodes attribute(s). somehow i always catch an exception "blabla has an invalid token"...
1
2579
by: Christian Rühl | last post by:
hey! what i wanna do sounds very simple at first, but it turned out to be a real bone crusher... i want to check if a treeView node is checked and if a correspondent node in my xml config file exists just to sort of synchronize them by changing the xml nodes attribute(s). somehow i always catch an exception "blabla has an invalid token"...
0
3283
by: divya1949 | last post by:
Create a windows c# application which will Read a xml file and populate nodes in the treeview. 1 On selection of treenode display the child nodes of that node in listview control 2. Provide following view properties to listview, through View menu a. Tile b. Icon
0
7452
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7387
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...
0
7643
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, 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. ...
0
7798
jinu1996
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...
0
5956
agi2029
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...
0
3441
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...
0
3436
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1004
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
688
bsmnconsultancy
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...

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.