|
|
|
Every now and then you need to fill a TreeView control with some random data, for example when you want to test a routine and you don't want to write a lot of code just for this secondary task. Here is a recursive routine that does the work for you: |
Click here to copy the following block |
Sub AddRandomNodes(TV As TreeView, Node As Node, MaxChildren As Integer, _ MaxLevel As Integer)
Dim i As Integer Dim child As Node
For i = 1 To CInt(Rnd * MaxChildren) Set child = TV.Nodes.Add(Node.index, tvwChild, , _ "Node #" & (TV.Nodes.Count + 1)) If CInt(Rnd * MaxLevel) Then AddRandomNodes TV, child, MaxChildren, MaxLevel - 1 End If Next End Sub |
You can use the above routine as follows: |
|
|
|
Submitted By :
Nayan Patel
(Member Since : 5/26/2004 12:23:06 PM)
|
|
|
Job Description :
He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |
View all (893) submissions by this author
(Birth Date : 7/14/1981 ) |
|
|