![]() ![]() Print Preview private void miPreview_Click( object sender, System.EventArgs e) Page Setup private void miSetup_Click( object sender, System.EventArgs e) While (linesPrinted = e.MarginBounds.Bottom) e)īrush brush = new SolidBrush(richTextBox1.ForeColor) OnPrintPage private void OnPrintPage( object sender, OnBeginPrint private void OnBeginPrint( object sender, If (printDialog1.ShowDialog() = DialogResult.OK) Print Event private void miPrint_Click( object sender, System.EventArgs e) RichTextBox1.AppendText( " I have also included Print Setup " " or any other text we wish to print.\r\n\r\n") " rich TextBox serves " " \r\n" " as a Cache for our Report, " RichTextBox1.AppendText( " This is the document we will print. " \r\n" " Visible Property to false.\r\n\r\n") We can place it anywhere on our form, and set the " " richTextBox it's physical dimensions are " " \r\n" The " " \r\n" " richTextBox does not " " or use Append Text, " " \r\n" " or Concatenate a String, and " RichTextBox1.AppendText( " We can write text to a richTextBox, " RichTextBox1.AppendText( " This is a greatly simplified Print " Form Load private void Form1_Load( object sender, System.EventArgs e)ĭ " /" " /" ![]() The " Print_Click" fires the " OnBeginPrint", and the " OnPrintPage" events. I have used a Main Menu at the top of the Windows Form with sub menu items as " PageSetup", " PrintPreview", and " Print". The rest of this Print method is fairly straightforward, and is available from any textbook, or "Microsoft Whitepapers". This greatly simplifies the printing process, and gives the developer an intuitive feel for printing in the. If I print a report ,for example, I write the date and header information at the top of the document, and then use richTextBox.AppendText any time I add text to the report. I can write literals to the control whenever necessary. If I am required to loop through a file, I can write a record to the control, using AppendText at every iteration. The RichTextBox.LoadFile will copy a text file to this control, or I can pass a string to the RichTextBox.Text property, and there after use the AppendText method at any point in the code. We can write to this control in a number of ways. RichTextBox's visible property can be set to false, and its physical dimensions on the form can be made very small. When I print a file, for example, using a RichTextBox, and printDocument, I drag a richTextBox onto our Windows Form, and then I place the control where it can be hidden. NET approach to Simplified Printing in which, we are going to use a RichTextBox to cache all of our text for printing in printDocument. ![]()
0 Comments
Leave a Reply. |