RichTextBox question

Hi to all of you, So far I have MDI with Child Form and RichTextBox on it. I can open either Text or RTF files (by changhing the code to RichTextBox.Text or .rtf) is it possible to select any file format without changing the code

Answer this question

RichTextBox question

  • Soahc

    jbattat wrote:
    Hi Mr. MarcD I was prompt that the "filecontent" property is new in Visual Studio, and for some reason the C# does not recognicing this word. are there any directive or way to get it

    FileContents would be the contents of the file that you read, etc.


  • WJ53418

    if I am understanding you correctly you could do one of the following

    if (IsRtf) { RichTextBox.rtf = filecontents } else { RichTextBox.Text = filecontents ;}

    you could also use a switch statement

    switch (Path.GetExtension(filename).ToLower())

    {

    case "rtf":

    case "doc":

    RichTextBox.rtf = filecontents

    break;

    case "txt"

    default:

    RichTextBox.Text = filecontents ;

    break;

    }


  • Eyaltac

    Hi Mr. MarcD I was prompt that the "filecontent" property is new in Visual Studio, and for some reason the C# does not recognicing this word. are there any directive or way to get it
  • Alessio Montagnini

    You will find that MarcD is infact stating that filecontent as in what ever your file content it, it could be a string variable or filestream or anything just "insert" your content there, also on his next example he also says "filename" meaning you could have a look at the <insert your filename here> to see what extension it has then work on it from there.

    Cheers,

    Michael Proctor



  • RichTextBox question