Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Pomoc oko stampe

[es] :: .NET :: .NET Desktop razvoj :: Pomoc oko stampe

[ Pregleda: 1527 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

divac
Ivan Urosevic
Project Manager
ICN Company / Elements System
Beograd

Član broj: 18317
Poruke: 55
*.ptt.rs.



+2 Profil

icon Pomoc oko stampe13.07.2011. u 15:08 - pre 155 meseci
Pozdrav svima. Treba mi mala pomoc oko stampe, posto nikako da ukapiram kako se stampa. Treba da uzimam podatke iz baze i da svaki podatak stampam na novoj strani. Uspeo sam bez problema da odstampam jednu stranu, ali nemam ideju gde da ubacim for petlju koja ce da kupi podatke iz baze, i da ih spremi za stampu.

Ono sto sam do sada uradio je sledece
Code (csharp):

private void OnPrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
                Brush brush = new SolidBrush(richTextBox1.ForeColor);
                Font font = new Font("Arial", 16.0f, FontStyle.Bold);

                e.Graphics.DrawString(ImePrezime, font, brush, e.PageBounds.Width / 3 * 2, e.PageBounds.Height / 2);
                e.Graphics.DrawString(Kompanija, font, brush, e.PageBounds.Width / 3 * 2, e.PageBounds.Height / 2 + font.Size + 10);
                Font font1 = new Font("Arial", 16.0f, FontStyle.Regular);
                e.Graphics.DrawString(Ulica, font1, brush, e.PageBounds.Width / 3 * 2, e.PageBounds.Height / 2 + font.Size + 10 + font.Size + 15);
                e.Graphics.DrawString(Grad, font1, brush, e.PageBounds.Width / 3 * 2, e.PageBounds.Height / 2 + font.Size + 10 + font.Size + 15 + font.Size + 8);
                e.Graphics.DrawString(Drzava, font1, brush, e.PageBounds.Width / 3 * 2, e.PageBounds.Height / 2 + font.Size + 10 + font.Size + 15 + font.Size + 8 + font.Size + 8);
        }


i ako mu rucno dam vrednosti za ImePrezime, Kompaniju... u Form_Load, to u print preview-u izbaci kako treba. Ali gde ubacivati podatke iz baze u ove promenjive i kako ??? Znaci ako uzmem 10 podataka iz baze, on u PrintPreview-u treba da mi izbaci 10 strana sa razlicitim podacima. Verujem da je ovo neka prosta stvar, ali izgleda da vazi pravilo da su proste stvari i najteze :)
Ivan Urosevic
 
Odgovor na temu

mish_ns
Miloš Krstin

Član broj: 159930
Poruke: 1105
...148.91.adsl.dyn.beotel.net.



+18 Profil

icon Re: Pomoc oko stampe13.07.2011. u 19:45 - pre 155 meseci
Trebalo bi da ubacis neki datagridView i u njega ucitas kolone iz baze koje ti trebaju.
i onda iz njega vadis podatke.
Ne znam napamet ali trebalo bi ovako:

e.Graphics.DrawString(dataGridView.Cell(0), font, brush, e.PageBounds.Width / 3 * 2, e.PageBounds.Height / 2);
e.Graphics.DrawString(dataGridView.Cell(1), font, brush, e.PageBounds.Width / 3 * 2, e.PageBounds.Height / 2 + font.Size + 10);

Imas i e.HasMorePages...to treba da postavis na true ako imas vise stranica za stampu.

Javi ako jos nesto zatreba.
Pozdrav
 
Odgovor na temu

divac
Ivan Urosevic
Project Manager
ICN Company / Elements System
Beograd

Član broj: 18317
Poruke: 55
*.ptt.rs.



+2 Profil

icon Re: Pomoc oko stampe13.07.2011. u 22:50 - pre 155 meseci
Resio sam problem posle celodnevnog mozganja. A u stvari je mnogo lako, kao sto sam i pretpostavio.

private void OnPrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
Brush brush = new SolidBrush(richTextBox1.ForeColor);
Font font = new Font("Arial", 16.0f, FontStyle.Bold);

e.Graphics.DrawString(dtContact.Rows[br]["ime"].ToString(), font, brush, e.PageBounds.Width / 5 * 3, e.PageBounds.Height / 2);
e.Graphics.DrawString(dtContact.Rows[br]["komp"].ToString(), font, brush, e.PageBounds.Width / 5 * 3, e.PageBounds.Height / 2 + font.Size + 10);
Font font1 = new Font("Arial", 16.0f, FontStyle.Regular);
e.Graphics.DrawString(dtContact.Rows[br]["ulica"].ToString(), font1, brush, e.PageBounds.Width / 5 * 3, e.PageBounds.Height / 2 + font.Size + 10 + font.Size + 15);
e.Graphics.DrawString(dtContact.Rows[br]["grad"].ToString(), font1, brush, e.PageBounds.Width / 5 * 3, e.PageBounds.Height / 2 + font.Size + 10 + font.Size + 15 + font.Size + 8);
e.Graphics.DrawString(dtContact.Rows[br]["drzava"].ToString(), font1, brush, e.PageBounds.Width / 5 * 3, e.PageBounds.Height / 2 + font.Size + 10 + font.Size + 15 + font.Size + 8 + font.Size + 8);
br++;

if (br < dtContact.Rows.Count)
e.HasMorePages = true;
}

U Form Load sam samo ucitao dataset, i ovaj kod je sve resio. Ono sto je bilo bitno, tj oko cega sam najvise vremena izgubio, je da ne treba da se radi nikakva for petlja, vec da brojac (br u mom primeru) treba rucno da se povecava. Cela mudrost :)
Ivan Urosevic
 
Odgovor na temu

[es] :: .NET :: .NET Desktop razvoj :: Pomoc oko stampe

[ Pregleda: 1527 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.