1 Replies - 1378 Views - Last Post: 17 December 2010 - 01:41 AM Rate Topic: -----

#1 star18  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 16-December 10

highlight the selected text in richtextbox

Posted 16 December 2010 - 08:21 PM

I would like to highlight the selected text by the user with cursor. The highlight button has the same function with the one in office word. Besides that, can anyone provide me some information on how to do the function such as bolding, font size and etc just like in the office word. I have no idea how to do this in visual studio 2010 c#. I am implementing my application in window forms. I try to googled it but found nothing. Your help is greatly appreciated. Thanks.

Is This A Good Question/Topic? 0
  • +

Replies To: highlight the selected text in richtextbox

#2 Gonzilla  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 23
  • Joined: 16-March 10

Re: highlight the selected text in richtextbox

Posted 17 December 2010 - 01:41 AM

Here is a little example how to bold a selected text.

private void Button_Bold(object sender, EventArgs e)
{
    if (richTextBox1.SelectionFont != null)
    {
        Font currentFont = richTextBox1.SelectionFont;
        FontStyle newFontStyle;

        newFontStyle = FontStyle.Bold;

        richTextBox1.SelectionFont = new Font(currentFont.FontFamily, currentFont.Size,newFontStyle);
    }
}


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1