如何在扩展所有节点的情况下打印Winfor Treeview控件? [英] How to print a Winfor Treeview controls with all node expanded ?

查看:55
本文介绍了如何在扩展所有节点的情况下打印Winfor Treeview控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



我想要打开一个Treeview控件,扩展所有节点。

晶体报告不支持这种类型的打印。

我该怎么做?



提前感谢。

Hello There,

I want to print a Treeview control with all nodes expanded.
The crystal report not supporting such type of printing.
How can i do that?

Thank in advance.

推荐答案

您是否尝试在树上进行完全展开?



此后使用继承的DrawToBitmap方法。

您可能需要在幕后,调整控件大小以显示所有项目。



Have you tried doing a full expand on the tree?

After this use the inherited DrawToBitmap method.
You will have to perhaps behind the scenes, resize the control to show all items.

treeview1.ExpandAll();

// If the treeview is not large enough to show the items,
// you will have to resize it first to show all items.

// I think that's about max for one page.
// However you can most likely do some scaling.
treeview1.Size = new Size(600,850);

// Create a bitmap.
Bitmap bmp = new Bitmap(treeview1.Width, treeview1.Height);

// Draw the treeview to the bitmap.
treeview1.DrawToBitmap(bmp, treeview1.ClientRectangle);

// Add the image to the clipboard.
// Clipboard.SetDataObject(bmp) works just the same.
Clipboard.SetImage(bmp);

// Create the Word App
Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application();

// Hide the word application or true if you want to see this all happening.
wordApp.Visible = false;

// Set the Missing type object.
object missing = System.Type.Missing;
 
//Open the doc file
Microsoft.Office.Interop.Word.Document wordDoc = wordApp.Documents.Add(missing, missing, missing, missing);

// Get the range, beginning at doc is 0,0
Microsoft.Office.Interop.Word.Range rng = wordDoc.Range(0,0); 

// Paste the image to the doc.
rng.Paste(); 

// Print out the doc with default printer, no special settings.
wordDoc.PrintOut(missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);





经过测试,效果很好..



Tested and works great..


这篇关于如何在扩展所有节点的情况下打印Winfor Treeview控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆