Click here to Skip to main content
15,890,512 members
Home / Discussions / C#
   

C#

 
AnswerRe: hi everybody! Pin
Christian Graus20-Sep-06 21:34
protectorChristian Graus20-Sep-06 21:34 
GeneralRe: hi everybody! Pin
Rob Manderson19-Jul-08 23:47
protectorRob Manderson19-Jul-08 23:47 
AnswerRe: hi everybody! Pin
Guffa20-Sep-06 21:50
Guffa20-Sep-06 21:50 
Questionc# mdi form application focus change problem Pin
orfur@orfur.com20-Sep-06 20:06
orfur@orfur.com20-Sep-06 20:06 
QuestionPrinter Is Print Slowly And Stoped....C# Pin
galigal1520-Sep-06 19:10
galigal1520-Sep-06 19:10 
AnswerRe: Printer Is Print Slowly And Stoped....C# Pin
Syed Mujtaba Hassan22-Sep-06 23:19
Syed Mujtaba Hassan22-Sep-06 23:19 
GeneralRe: Printer Is Print Slowly And Stoped....C# Pin
galigal1523-Sep-06 12:10
galigal1523-Sep-06 12:10 
GeneralRe: Printer Is Print Slowly And Stoped....C# Pin
Syed Mujtaba Hassan25-Sep-06 0:18
Syed Mujtaba Hassan25-Sep-06 0:18 
One simple way is that when you save text in RTF format you can then load it in MSWord or any other word processor and print them out. If you want to add RTF viewer or editor to your project then make a new form and add Rich text box to you form and by calling its methods you can manipulate all the things required.
Here is an example.
public void CreateMyRichTextBox()<br />
{<br />
    RichTextBox richTextBox1 = new RichTextBox();<br />
    richTextBox1.Dock = DockStyle.Fill;                 //Cover up maximum area in the form.<br />
<br />
<br />
    richTextBox1.LoadFile("C:\\MyDocument.rtf");              //Files can be loaded in this way.<br />
    richTextBox1.Find("Text", RichTextBoxFinds.MatchCase);             //String operations can be performed.<br />
<br />
    richTextBox1.SelectionFont = new Font("Verdana", 12, FontStyle.Bold);  //Fonts can be set.<br />
    richTextBox1.SelectionColor = Color.Red;              //Text selection operations<br />
<br />
    richTextBox1.SaveFile("C:\\MyDocument.rtf",    RichTextBoxStreamType.RichText);                         //Files can be saved.<br />
<br />
    this.Controls.Add(richTextBox1);              //To add richtext box to form.<br />
}<br />




For printing checkout PRINTDIALOGUE properties. You have to bind the print dialogue to you page.
Here is an example.

<br />
// Declare the PrintDocument object.<br />
private System.Drawing.Printing.PrintDocument docToPrint = <br />
    new System.Drawing.Printing.PrintDocument();<br />
<br />
// This method will set properties on the PrintDialog object and<br />
// then display the dialog.<br />
private void Button1_Click(System.Object sender, <br />
    System.EventArgs e)<br />
{<br />
<br />
    // Allow the user to choose the page range he or she would<br />
    // like to print.<br />
    PrintDialog1.AllowSomePages = true;<br />
<br />
    // Show the help button.<br />
    PrintDialog1.ShowHelp = true;<br />
<br />
    // Set the Document property to the PrintDocument for <br />
    // which the PrintPage Event has been handled. To display the<br />
    // dialog, either this property or the PrinterSettings property <br />
    // must be set <br />
    PrintDialog1.Document = docToPrint;<br />
<br />
    DialogResult result = PrintDialog1.ShowDialog();<br />
<br />
    // If the result is OK then print the document.<br />
    if (result==DialogResult.OK)<br />
    {<br />
        docToPrint.Print();<br />
    }<br />
    <br />
}<br />
<br />
// The PrintDialog will print the document<br />
// by handling the document's PrintPage event.<br />
private void document_PrintPage(object sender, <br />
    System.Drawing.Printing.PrintPageEventArgs e)<br />
{<br />
<br />
    // Insert code to render the page here.<br />
    // This code will be called when the control is drawn.<br />
<br />
    // The following code will render a simple<br />
    // message on the printed document.<br />
    string text = "In document_PrintPage method.";<br />
    System.Drawing.Font printFont = new System.Drawing.Font<br />
        ("Arial", 35, System.Drawing.FontStyle.Regular);<br />
<br />
    // Draw the content.<br />
    e.Graphics.DrawString(text, printFont, <br />
        System.Drawing.Brushes.Black, 10, 10);<br />
}<br />
<br />
<br />



Mujtaba

GeneralRe: Printer Is Print Slowly And Stoped....C# Pin
galigal1525-Sep-06 1:32
galigal1525-Sep-06 1:32 
GeneralRe: Printer Is Print Slowly And Stoped....C# Pin
Syed Mujtaba Hassan25-Sep-06 19:02
Syed Mujtaba Hassan25-Sep-06 19:02 
GeneralRe: Printer Is Print Slowly And Stoped....C# Pin
galigal1526-Sep-06 1:46
galigal1526-Sep-06 1:46 
GeneralRe: Printer Is Print Slowly And Stoped....C# Pin
Syed Mujtaba Hassan27-Sep-06 22:58
Syed Mujtaba Hassan27-Sep-06 22:58 
QuestionPrinter Is Print Slowly And Stoped...... Pin
galigal1520-Sep-06 19:07
galigal1520-Sep-06 19:07 
Questionhow to recognise thread Pin
Parshant Verma20-Sep-06 18:57
Parshant Verma20-Sep-06 18:57 
AnswerRe: how to recognise thread Pin
S. Senthil Kumar20-Sep-06 20:07
S. Senthil Kumar20-Sep-06 20:07 
QuestionFew qustions Pin
NaNg1524120-Sep-06 18:08
NaNg1524120-Sep-06 18:08 
AnswerRe: Few qustions Pin
yueue20-Sep-06 19:00
yueue20-Sep-06 19:00 
GeneralRe: Few qustions Pin
NaNg1524121-Sep-06 7:23
NaNg1524121-Sep-06 7:23 
QuestionWhich Control is Best To Draw Graphs? Pin
...---...20-Sep-06 16:17
...---...20-Sep-06 16:17 
AnswerRe: Which Control is Best To Draw Graphs? Pin
Christian Graus20-Sep-06 16:44
protectorChristian Graus20-Sep-06 16:44 
AnswerRe: Which Control is Best To Draw Graphs? Pin
Judah Gabriel Himango20-Sep-06 16:45
sponsorJudah Gabriel Himango20-Sep-06 16:45 
AnswerRe: Which Control is Best To Draw Graphs? Pin
yueue20-Sep-06 19:03
yueue20-Sep-06 19:03 
QuestionTrue/False DB Field display Yes/No instead Pin
Glen Harvy20-Sep-06 15:04
Glen Harvy20-Sep-06 15:04 
AnswerRe: True/False DB Field display Yes/No instead Pin
Christian Graus20-Sep-06 15:12
protectorChristian Graus20-Sep-06 15:12 
GeneralRe: True/False DB Field display Yes/No instead Pin
Glen Harvy20-Sep-06 15:20
Glen Harvy20-Sep-06 15:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.