CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Rtb @ C#

  1. #1
    Join Date
    Apr 2003
    Posts
    15

    Question Rtb @ C#

    when i change text color at RTB by SelectionColor, i see the selection flickering.
    how can prevent the RTB from updating view, until i finish coloring?

  2. #2
    Join Date
    Feb 2003
    Location
    Israel
    Posts
    102
    what are you trying to do?
    give us more details about what you're doing.

  3. #3
    Join Date
    Apr 2003
    Posts
    15
    My question:
    Is there another way to color text on rich text box, without using SelectionColor(,)?

    Coloring text with SelectionColor() is not good enough, because its take too much time, and i see the text selected and unselected.
    I have lot of text to color and it take many seconds till it finish.
    Last edited by RPG2KILL; April 10th, 2003 at 10:05 AM.

  4. #4
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    you may try out,
    richTextBox1.Focus();

    richTextBox1.SelectionColor = Color.Red;

    richTextBox1.SelectionFont = new Font ("Courier", 10, FontStyle.Bold);
    - Software Architect

  5. #5
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    try

    {

    int start = richTextBox1.SelectionStart;

    int len = richTextBox1.SelectionLength;

    System.Drawing.Font currentFont;

    FontStyle fs;

    for(int i = 0; i < len; ++i)

    {

    richTextBox1.Select(start + i, 1);

    currentFont = richTextBox1.SelectionFont;

    fs = currentFont.Style;

    //add style

    fs = fs | style;

    richTextBox1.SelectionFont = new Font(

    currentFont.FontFamily,

    currentFont.Size,

    fs

    );

    }

    }



    private void RemoveFontStyle(FontStyle style)

    {

    int start = richTextBox1.SelectionStart;

    int len = richTextBox1.SelectionLength;

    System.Drawing.Font currentFont;

    FontStyle fs;

    for(int i = 0; i < len; ++i)

    {

    richTextBox1.Select(start + i, 1);

    currentFont = richTextBox1.SelectionFont;

    fs = currentFont.Style;

    //remove style

    fs = fs & ~style;

    richTextBox1.SelectionFont = new Font(

    currentFont.FontFamily,

    currentFont.Size,

    fs

    );

    }

    }



    private void button1_Click(object sender, System.EventArgs e)

    {

    AddFontStyle(FontStyle.Bold);

    }
    - Software Architect

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured