You must Sign In to post a response.
  • Category: .NET

    Working with RicheTextBox

    Hi,

    I have a .rtf file where the words are formatted like bold, italics,underlined etc.
    And I have to show this file into a textbox in C# application.
    I am using both textbox and richtextbox for the same. The text is showing into the Textbox but the formatting is not working.
    Can any body help on this?


    Thank You,
    Binay Kumar Prasad.
  • #764899
    Hai Binay,
    It seems that the text you are adding is read-only mode and its not under the formatted output.
    You need to write the html text and then it will work.
    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com

  • #764901
    The good way is to load RTF in textbox directly, see below snippet
    public void LoadMyFile()
    {
    // Create an OpenFileDialog to request a file to open.
    OpenFileDialog openFile1 = new OpenFileDialog();

    // Initialize the OpenFileDialog to look for RTF files.
    openFile1.DefaultExt = "*.rtf";
    openFile1.Filter = "RTF Files|*.rtf";

    // Determine whether the user selected a file from the OpenFileDialog.
    if(openFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK &&
    openFile1.FileName.Length > 0)
    {
    // Load the contents of the file into the RichTextBox.
    richTextBox1.LoadFile(openFile1.FileName);
    }
    }

    this code works with C# windows appliction

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #764917
    Hi,

    You can use rich textbox in C# please refer below code and see if it helps,
    http://www.c-sharpcorner.com/uploadfile/mahesh/richtextbox-in-C-Sharp/


    Regards,
    Asheej T K
    Microsoft MVP[ASP.NET/IIS]
    DotNetSpider MVM

  • #764979
    You are using RichTextBox in the windows application or a web based application ?
    Miss. Jain
    Microsoft Certified Technology Specialist in .Net


Sign In to post your comments