title image


Smiley Coding
public void PageCreate(string printerName, string pageTitle, string sSort, int index)

{

BeitragFacade beitragfacade = new BeitragFacade();

StringBuilder sb = new StringBuilder();

DataRow[] rowsBericht;

DataView dview = new DataView(vmbDataset.vBericht);



//Daten von der DB holen

beitragfacade.getBericht(vmbDataset.vBericht, index);

rowsBericht = vmbDataset.vBericht.Select("","Mitgliedschaft");



try

{

//Titel der Zeitschrift

sb.Append(pageTitle +"\n"+" " + sSort + "\n\n" );



foreach(DataRow r in vmbDataset.vBericht.Rows)

{

//titel

sb.Append(r[1].ToString() + "\n");

....

}



// place stringbuilder in string reader

stringToPrint = new StringReader(sb.ToString());



// set font and size here

printFont = new Font("Arial", 12);



PrintDocument doc = new PrintDocument();



// set the printer name

doc.PrinterSettings.PrinterName = printerName;



// add print page event handler

doc.PrintPage += new PrintPageEventHandler(this.PagePrint);



// print the page

doc.Print();

}

catch

{}

finally

{

stringToPrint.Close() ;

}

}



private void PagePrint(object sender, PrintPageEventArgs e)

{

float linesPerPage = 0 ;

float linePosition = 0 ;

int lineCount = 0 ;



float leftMargin = e.MarginBounds.Left;

float topMargin = e.MarginBounds.Top;



String line=null;



// gets the number of lines per page

linesPerPage = e.MarginBounds.Height / printFont.GetHeight(e.Graphics) ;



// iterate lines in string

while (lineCount < linesPerPage && ((line=stringToPrint.ReadLine()) != null))

{



// set line postion from top margin

linePosition = topMargin + (lineCount * printFont.GetHeight(e.Graphics));



// print line

e.Graphics.DrawString (line, printFont, Brushes.Black, leftMargin,linePosition, new StringFormat());

lineCount++;

}



// are there more lines?

if (line != null)

e.HasMorePages = true ;

else

e.HasMorePages = false ;

}



geschrieben von

Login

E-Mail:
  

Passwort:
  

Beitrag anfügen

Symbol:
 
 
 
 
 
 
 
 
 
 
 
 
 

Überschrift: