private void ShowPic() { var rows = dgvList.SelectedRows; if (rows.Count == 0) { return; } var index = rows[0].Index; var ro = dgvList.Rows[index]; var tableName = ro.Cells[0].Value.ToString().Trim(); var dest = ro.Cells["存储文件"].Value.ToString().Trim(); if (String.IsNullOrEmpty(dest)) { MessageBox.Show("无发票文件"); return; } var path = dest; if (!File.Exists(path)) { return; } var temp = Image.FromFile(path); var form2 = new FormPrintResult(temp); form2.PreUpdateTable = UpdateTable; form2.ShowDialog(); // form2.Dispose(); }
private void Print() { var ppc = new PrintPreviewControl(); pd = printDocument; var margins = new Margins(20, 20, 20, 20); pd.DefaultPageSettings.Margins = margins; pd.DefaultPageSettings.Landscape = true; pd.PrintPage += pd_PrintPage; ppc.Document = pd; FormPrintResult formPreview = new FormPrintResult(ppc); formPreview.PreUpdateTable = new Action(UpdateTable); // formPreview.Controls.Add(ppc); // var s=formPreview.Controls["pnlPic"]; // s.Controls.Add(ppc); // formPreview.Controls["pnlPic"].Dock = DockStyle.Fill; formPreview.ShowDialog(); formPreview.Dispose(); // DialogResult result = ppdPicture.ShowDialog(); // PreUpdateTable(); }