Ver Mensaje Individual
  #5 (permalink)  
Antiguo 16/08/2011, 11:11
Avatar de costesensey2
costesensey2
 
Fecha de Ingreso: noviembre-2010
Mensajes: 38
Antigüedad: 13 años, 5 meses
Puntos: 0
Respuesta: problema para resolver

tengo este para imprimir

private void btnImprimir_Click(object sender, EventArgs e)
{
PrintDialog printDialog = new PrintDialog();
printDialog.Document = printDocument;
DialogResult result = printDialog.ShowDialog();
if (result == DialogResult.OK)
{
printDocument.Print();
}
}

private int i = 0;

private void printDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
Font pr = new Font("Arial", 10);
float top = e.MarginBounds.Top;
float ypos = 0;
float lines = 0;
int count = 0;
string texto = "";
DataGridViewRow row;

lines = e.MarginBounds.Height / pr.GetHeight(e.Graphics);

while (count < lines && i < this.grd.Rows.Count)
{
row = grd.Rows[i];
texto = "";

foreach(DataGridViewCell celda in row.Cells)
{
texto += "\t" + celda.Value.ToString();
}

ypos = top + (count * pr.GetHeight(e.Graphics));
e.Graphics.DrawString(texto, pr, Brushes.Black, 10, ypos);
//count++;
//i++;
}

if (i < this.grd.Rows.Count)
{
e.HasMorePages = true;
}
else
{
e.HasMorePages = false;
i = 0;
}

}