我正在编写一个代码来保存表单的内容,当被要求显示它时,它应该作为表单本身打开。就像我如何保存它
我试过这个
Private Sub save_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Save.Click
' Displays a SaveFileDialog so the user can save the file assigned to the Save button.
Dim saveFileDialog1 As New SaveFileDialog()
saveFileDialog1.Filter = "All Files|*.*|Excel Files|*.xls|Word Files|*.doc"
saveFileDialog1.InitialDirectory = "R:\Clinical\General\Shifts"
saveFileDialog1.Title = "Save Shift File"
saveFileDialog1.FilterIndex = 1
saveFileDialog1.ShowDialog()
End Sub
但是我打开了它,它显示在记事本中,因为它是一个.txt文件。但我希望它作为一种形式打开。 帮帮我吧。
答案 0 :(得分:0)
最简单的方法是保存表单的图像:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim strFilename As String = "C:\Junk\Junk.bmp"
Dim bmp As New Bitmap(Me.Width, Me.Height)
Me.DrawToBitmap(bmp, New Rectangle(0, 0, Me.Width, Me.Height))
bmp.Save(strFilename)
bmp.Dispose()
End Sub