Microsoft Communities

Welcome to WindowsClient.net | Sign in | Join

Here are some frequently asked questions about Windows Forms and their answers.

Windows Forms FAQs

How do I create and save a rich text format (RTF) file?

One way to do this is to use the RichTextBox.SaveFile method.

private void button1_Click( object sender, EventArgs e )
{
  // get a file name from the user
  SaveFileDialog saveFile1 = new SaveFileDialog();
  saveFile1.DefaultExt = "*.rtf";
  saveFile1.Filter = "RTF Files|*.rtf";
  if ( saveFile1.ShowDialog() == DialogResult.OK )
    richTextBox1.SaveFile( saveFile1.FileName, RichTextBoxStreamType.RichText )
}

Contributed from George Shepherd's Windows Forms FAQ



Page view counter