Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Treeview - print

Status
Not open for further replies.

Ajb2528

Technical User
Feb 22, 2002
270
GB
Has anyone know of a way - preferably in VB.Net to print the nodes (together with associated icons and lines) for a treeview. I have found some code on The Code Project but this is written in C# and uses a bitmap and it doesn't work properly - it truncates after a few pages.

Any suggestions/help will be appreciated!

Regards,

Alan
 
You will need to add a Treeview control to your form called Treeview1 and an ImageList control called ImageList1. Add two images to the ImageList control, then drop this code in the Form_Load and run the project.


Dim i As Integer
Dim J As Integer

With TreeView1
.ShowRootLines = True
.ShowPlusMinus = True
.ImageList = ImageList1
End With

i = 1

For i = 1 To 40
Dim nodp As New Windows.Forms.TreeNode("Node" & i.ToString, 0, 0)
TreeView1.Nodes.Add(nodp)

For J = 1 To 4
Dim nodc As New Windows.Forms.TreeNode("SubNode" & i.ToString, 1, 1)
nodp.Nodes.Add(nodc)
Next
Next
 
aajay,

Thanks for the reply but this shows me how to add nodes to a treeview - not print them.

Regards,

Alan
 
try this
Private Sub PrintRecursive(ByVal n As TreeNode)
System.Diagnostics.Debug.WriteLine(n.Text)
MessageBox.Show(n.Text)
Dim aNode As TreeNode
For Each aNode In n.Nodes
PrintRecursive(aNode)
Next
End Sub
 
aajay,

Thanks again for the reply, I have seen an example like this on MSDN. What I require is to be able to print a more or less exact replica of the Treeview complete with lines and associated icons (with a header) over many pages if it is required.

Regards,

Alan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top