Salve a tutti, mi sto approcciando al C# e sto sviluppando un piccolo progetto, mi sono imbattutto in diversi problemi per generare una stampa con anteprima, alcuni li ho superati, ma questo non rieco proprio.
ho una query linq dichiarata come EnumerableRowCollection che può produrre svariate righe, non riesco ad aggiungere pagine nuove e continuare la stampa.
Questa è la query
codice:EnumerableRowCollection qry; /* altro codice tra cui la connessione ad un file access da cui recupero i dati popolando una DataTable chiamato res */ qry = from d in res.AsEnumerable() where d.Field<DateTime>("DATORD") >= DALd where d.Field<DateTime>("DATORD") <= ALd where d.Field<string>("TIPO").Substring(0, 1) == "R" where d.Field<string>("CAU_UFF_OR") != "1" where d.Field<string>("CAU_UFF_OR") != "10" where d.Field<string>("CAU_UFF_OR") != "30" where d.Field<string>("CAU_UFF_OR") != "40" where d.Field<string>("CAU_UFF_OR") != "60" orderby d.Field<string>("CAU_UFF_OR") ascending select d;non so come andare avanti....codice:/* chiaramente non funziona bene, ma al momento la funzione che genera il documento è questa */ private void prnDoc_Printpage(object sender, PrintPageEventArgs e) { Graphics graphics = e.Graphics; SolidBrush fColor = new SolidBrush(Color.Black); int linePerPage = 0; int fontHeight = (int)docFont.GetHeight(e.Graphics); int topMargin = e.MarginBounds.Top; int startX = 50; int startY = 50; int Ypos = 0; int count = 0; // max linee per pagina linePerPage = (e.MarginBounds.Height / fontHeight) - 2; // intestazione graphics.DrawString(intestazione, docFont, fColor, startX, startY); string divisione = "----------------------------------------------------------------------------------------------------"; int totRighe = 0; foreach (DataRow r in qry) { totRighe++; } while (count < linePerPage && count < totRighe) { foreach (DataRow r in qry) { Ypos = topMargin + (count * (fontHeight * 2)) + startY + 30; string riga = "Ord. " + r.Field<string>("NORD") + " - " + r.Field<string>("DESCLI") + "\n" + divisione + "\n\n"; graphics.DrawString(riga, docFont, fColor, startX, Ypos, new StringFormat()); count++; } } //if (line != null) { e.HasMorePages = true; } //else { e.HasMorePages = false; } }
grazie a tutti in aticipo per qualsiasi aiuto e suggerimento!

Rispondi quotando