Inhalt einer richTextBox drucken

05/11/2007 - 00:44 von Tizi | Report spam
Wer kann mir sagen, wie ich anstatt "TEST" einen Text aus der richTextBox
drucken kann
private: System::Void printDocument1_PrintPage(System::Object^ sender,
System::Drawing::Printing::PrintPageEventArgs^ e)
{
String^ drawString ="TEST";

// Create font and brush.
System::Drawing::Font^ drawFont = gcnew System::Drawing::Font(
"Arial",16 );
SolidBrush^ drawBrush = gcnew SolidBrush( Color::Black );

// Create rectangle for drawing.
float x = 150.0F;
float y = 150.0F;
float width = 200.0F;
float height = 50.0F;
RectangleF drawRect = RectangleF(x,y,width,height);

// Draw rectangle to screen.
Pen^ blackPen = gcnew Pen( Color::Black );
e->Graphics->DrawRectangle( blackPen, x, y, width, height );

// Draw string to screen.
e->Graphics->DrawString( drawString, drawFont, drawBrush, drawRect );
}
s
 

Lesen sie die antworten

#1 Wolfgang Schlicker
09/11/2007 - 12:04 | Warnen spam
Hallo Tizi,

schau mal unter http://msdn2.microsoft.com/en-us/li...96492.aspx

Ich habe dir den "Client Code" auf MCPP angepasst. Binde dazu einfach das C#
oder VB Projekt des RichEditTextEx in dein eigenes Projekt ein.
der folgende Code sollte dir dann weiterhelfen:













































































private int its_nFirstCharOnPage;

private: System::Void printDocument_BeginPrint(System::Object^ sender,
System::Drawing::Printing::PrintEventArgs^ e)
{
// Start at the beginning of the text
its_nFirstCharOnPage = 0;
}

private: System::Void printDocument_PrintPage(System::Object^ sender,
System::Drawing::Printing::PrintPageEventArgs^ e)
{
// To print the boundaries of the current page margins
// uncomment the next line:
//e->Graphics->DrawRectangle(System::Drawing::Pens::Blue,
e->MarginBounds);

// make the RichTextBoxEx calculate and render as much text as will
// fit on the page and remember the last character printed for the
// beginning of the next page
its_nFirstCharOnPage = richTextBoxEx->FormatRange(false,
e,
its_nFirstCharOnPage,
richTextBoxEx->TextLength);

// check if there are more pages to print
if (its_nFirstCharOnPage < richTextBoxEx->TextLength)
e->HasMorePages = true;
else
e->HasMorePages = false;
}

private: System::Void printDocument_EndPrint(System::Object^ sender,
System::Drawing::Printing::PrintEventArgs^ e)
{
// Clean up cached information
richTextBoxEx->FormatRangeDone();
}

<<<<<<<<<<<<<<<<<<<<<<<<

Grüsse,
Wolfgang

Ähnliche fragen