Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 在一个文档中保存多个图表_Vb.net_Visual Studio 2010_Charts - Fatal编程技术网

Vb.net 在一个文档中保存多个图表

Vb.net 在一个文档中保存多个图表,vb.net,visual-studio-2010,charts,Vb.net,Visual Studio 2010,Charts,我正在寻找一种在一个文档中保存3个不同图表的方法。 我的程序计算了一些数据,这些数据将显示在3个不同的图表中 我有图表1、图表2和图表3 我找到了这段代码,它只能在一个文档中将一个图表另存为一个图像 01 ' Displays a SaveFileDialog so the user can save the Image 02 ' assigned to Button2. 03 Dim saveFileDialog1 As New SaveFileDialog(

我正在寻找一种在一个文档中保存3个不同图表的方法。 我的程序计算了一些数据,这些数据将显示在3个不同的图表中 我有图表1、图表2和图表3 我找到了这段代码,它只能在一个文档中将一个图表另存为一个图像

01  ' Displays a SaveFileDialog so the user can save the Image
02         ' assigned to Button2.
03         Dim saveFileDialog1 As New SaveFileDialog()
04         saveFileDialog1.Filter = "JPeg Image|*.jpg|Bitmap Image|*.bmp|Gif       Image|*.gif"
05         saveFileDialog1.Title = "Save an Image File"
06         saveFileDialog1.ShowDialog()
07   
08         ' If the file name is not an empty string open it for saving.
09         If saveFileDialog1.FileName <> "" Then
10             ' Saves the Image via a FileStream created by the OpenFile method.
11             Dim fs As System.IO.FileStream = CType _
12                (saveFileDialog1.OpenFile(), System.IO.FileStream)
13             ' Saves the Image in the appropriate ImageFormat based upon the
14             ' file type selected in the dialog box.
15             ' NOTE that the FilterIndex property is one-based.
16             Select Case saveFileDialog1.FilterIndex
17                 Case 1
18                     Chart1.SaveImage(fs, _
19                        System.Drawing.Imaging.ImageFormat.Jpeg)
20   
21                 Case 2
22                     Chart1.SaveImage(fs, _
23                        System.Drawing.Imaging.ImageFormat.Bmp)
24   
25                 Case 3
26                     Chart1.SaveImage(fs, _
27                        System.Drawing.Imaging.ImageFormat.Gif)
28             End Select
01'显示保存文件对话框,以便用户保存图像
02'分配给按钮2。
03 Dim saveFileDialog1作为新的SaveFileDialog()
04 saveFileDialog1.Filter=“JPeg图像|*.jpg |位图图像|*.bmp | Gif图像|*.Gif”
05 saveFileDialog1.Title=“保存图像文件”
06 saveFileDialog1.ShowDialog()
07
08'如果文件名不是空字符串,请打开它进行保存。
09如果保存文件对话框1.FileName“”,则
10'通过OpenFile方法创建的文件流保存图像。
11 Dim fs As System.IO.FileStream=CType_
12(saveFileDialog1.OpenFile(),System.IO.FileStream)
13'根据
在对话框中选择14'文件类型。
15'请注意,FilterIndex属性是基于一个的。
16选择案例保存文件对话框1.FilterIndex
17案例1
18图表1.保存图像(fs、_
19系统.绘图.成像.图像格式.Jpeg)
20
21案例2
22图表1.保存图像(fs_
23.System.Drawing.Imaging.ImageFormat.Bmp)
24
25案例3
26图表1.保存图像(fs_
27.System.Drawing.Imaging.ImageFormat.Gif)
28终端选择

是否有人建议通过单击我的vb.net程序中的按钮将3个不同的图表保存到一个文档中?

您应该将每个图表写入一个文件:

Chart1.SaveImage(fs & 1, System.Drawing.Imaging.ImageFormat.Jpeg)
Chart2.SaveImage(fs & 2, System.Drawing.Imaging.ImageFormat.Jpeg)
Chart3.SaveImage(fs & 3, System.Drawing.Imaging.ImageFormat.Jpeg)
将使用Graphics.DrawImage从这些文件创建新图形(

然后,您可以使用Image.save()将此图像编译保存到一个文件中


玩得开心!

这超出了我的专业知识范围。第一个链接不起作用。我尝试过你的建议,但对我不起作用