private void button3_Click(object sender, EventArgs e) { Impresion imp = new Impresion(3); imp.ShowDialog(); }
private void button1_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count > 0) { Impresion imp = new Impresion(int.Parse(dataGridView1.SelectedRows[0].Cells["facturaID"].Value.ToString())); imp.ShowDialog(); } else { MessageBox.Show("Seleccioná una factura para imprimir!"); } /* CODIGO VIEJO DE IMPRESIÒN * * * buttonCerrarFactura.Visible = false; * buttonImprimir.Visible = false; * buttonEditar.Visible = false; * buttonEliminar.Visible = false; * PrintDocument pd = new PrintDocument(); * pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage); * * * * * //Creo un gráfico * Graphics myGraphics = this.CreateGraphics(); * * //Calculo posiciones y tamaños absolutos * Point startPoint = panel1.PointToScreen(new Point()); * Point endPoint = puntoFinal.PointToScreen(new Point()); * int ancho = endPoint.X - startPoint.X; * alto = endPoint.Y - startPoint.Y; * Size s = new Size(ancho, alto); * //Creo una imagen usando los parámetros de posició y tamaño absoluto * memoryImage = new Bitmap(s.Width, s.Height, myGraphics); * //Al gráfico le cargo el molde de la imagen * Graphics memoryGraphics = Graphics.FromImage(memoryImage); * * memoryGraphics.CopyFromScreen(startPoint.X, startPoint.Y, 0, 0, s); * objBitmap = new Bitmap(memoryImage, new Size(750, alto)); * * * * * PrintDialog printdlg = new PrintDialog(); * PrintPreviewDialog printPrvDlg = new PrintPreviewDialog(); * * // preview the assigned document or you can create a different previewButton for it * printPrvDlg.Document = pd; * * * printdlg.Document = pd; * printPrvDlg.ShowDialog(); * if (printdlg.ShowDialog() == DialogResult.OK) * { * pd.Print(); * } * buttonCerrarFactura.Visible = true; * buttonImprimir.Visible = true; * buttonEditar.Visible = true; * buttonEliminar.Visible = true; * * * FIN DE CODIGO VIEJO */ }