notepad

Hi to all,

Iam implementing a notepad application.When i seleceted from Format->font menu the fonts are applied to the existing text in the textbox.After applying i saved the application.But the selected fonts from the Font menu are not applied to the text

I used the following code for saving

streamwriter sw = new StreamWriter(--filename);

sw.Write(textBox1.Text);

sw.Close();

Please help me.

Thanks in advance.




Answer this question

notepad

  • DrBytes

    This is because plain textfiles don't include fonts. You must use RTF for example, put a RichtTextbox on your form and use the Save method of it to save the current Text in RTF format to a file. Then the Font is stored, but also other properties like images, font style, color's etc.


  • picflight

    You are welcome


  • vinaypugalia

    Hi,

    In the open file dialog written this code to load the file

    richTextBox1.LoadFile(openFileDialog1.FileName);

    It is giving an exception ,File format is not valid.

    in save dialog i used .txt as default extension.

    The above load file() will load the .rtf or ASCII text files.but why it is giving the above exception.

    Please help me.

    Thanks in advance.



  • MUSIC56522

    Hi,

    I placed the rich text box,and fonts are applied to the richtext box.

    Now to save the changes to a file i used the following statement

    richTextBox1.SelectionFont = new Font(fontname, fontsize, fstyle);

    richTextBox1.SaveFile(fn, RichTextBoxStreamType.RichText);

    where fn contains th filename.

    but now also the changes are not applied to the file.

    Please help me.



  • LSanders

    Hi

    thank you very much for your valuble information.



  • Mansour K.

    You load this file into you richTextBox by opening this file


  • Landale

    You must load a RichText formatted file. When you do that, does it work then


  • notepad