Private Sub btnExportPDF_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles btnExportPDF.Click
Dim cRpt As New CrystalReportDietRecord()
Dim saveFilePdf As New SaveFileDialog
' < Set file name and file type together with show save as dialog. >
saveFilePdf.FileName = "DietRecord"
saveFilePdf.Filter = "pdf files (*.pdf)|*.pdf"
saveFilePdf.ShowDialog()
' < Crystal Report by using data from datatable(dtDietRecord) for export report file. >
cRpt.SetDataSource(dtDietRecord) 'dtDietRecord คือ datatable ที่เราได้ตั้งแต่ตอนแสดงขอมูลใน datagrid
cRpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, saveFilePdf.FileName)
End Sub