openFileDialog1.Filter = "Text Files*.txtWord documents*.doc";
openFileDialog1.FileName = "Select file";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
rtb1.LoadFile(openFileDialog1.FileName, RichTextBoxStreamType.PlainText);
}
PrintDocument
private void printToolStripMenuItem_Click(object sender, EventArgs e)
{
PrintDocument doc = new PrintDocument();
doc.PrintPage += new PrintPageEventHandler(doc_PrintPage);
doc.Print();
}
void doc_PrintPage(object sender, PrintPageEventArgs e)
{
Font f = new Font("Arial", 18, FontStyle.Italic);
Font f2 = new Font("Tahoma", 14, FontStyle.Bold);
e.Graphics.DrawString("Document", f, Brushes.Brown, 25, 50);
e.Graphics.DrawString("'"+rtb1.Text+"'", f2, Brushes.Brown, 25, 50);
//throw new Exception("The method or operation is not implemented.");
}
No comments:
Post a Comment