将部分 Windows 窗体导出为图像
我有一个表格,显示在 Microsoft Chart 控件 6.0 中制作的图表...
我在菜单栏中放置了一个选项,它将导出制作的图表到图像文件...
有人能告诉我如何导出图表部分吗将表单作为图像(任何格式都可以)...
我正在考虑截取屏幕截图并保存它,但我无法在 VB 中获取控件来截取表单上指定区域的屏幕截图。
I have a form which shows a graph which was made in Microsoft Chart control 6.0...
I have placed a option in the menubar which will export the graph made to an image file...
Can some one tell how to export the graph part of the form as a image (any format will do)...
I was thinking of taking a screenshot and saving it but i cudnt get the controls in vb to take a screenshot of a specified area on the form.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这是它的 C# 函数
并调用
这是上面转换为 VB 的 C# 方法
here's the C# function for it
and call
Here's the above c# method converted to VB
尝试以下代码:
导入 System.Drawing.Imaging
Try this code:
Imports System.Drawing.Imaging
要查看的关键方法是 Control.DrawToBitmap。
这是一个返回由函数参数指定的控件的
Bitmap
的函数:您可以像这样使用该函数:
代码有点粗糙,但我相信它为您指明了正确的方向。
The key method to look at is Control.DrawToBitmap.
Here's a function that returns an
Bitmap
of a control specified by the function parameter:You can use this function like this:
The code's a bit rough but I believe it points you in the right direction.
阅读 Visual Basic 文档,如何找到类之间的链接控件并不明显。
我假设实现使用表单保存 PaintEvent 的主要命令是
.CreateGraphics()
命令命名为表单我。
属性。我的下一个假设是 creategraphics 添加图像到
控制逻辑的一部分。改变外观
,例如button1控件creategraphics就是要考虑
开发环境。
上面的代码已经测试过了。可以保存paintevent。为了编译,我使用了从命令行创建 Windows 窗体应用程序,
It is not obvious, reading visual basic documentations, how to find the linked control between the classes.
I assume the main commands to achieve saving a paintevent with a form are
.CreateGraphics()
command as formMe.
property. My next assumption is the creategraphics add an image to
a part of a control logic. To change the appearance of a
,for example, button1 control creategraphics is to consider
the development environment.
The above code is tested. The paintevent can be saved. For compiling i used Create a Windows Forms application from the command line,