473,385 Members | 1,588 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,385 software developers and data experts.

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 3026
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********@gmail.comschreef in bericht
news:11**********************@c51g2000cwc.googlegr oups.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
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
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...
2
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...
1
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...
0
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...
3
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
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...
1
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...
0
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. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
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
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...
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,...
0
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...

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.