Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 27th, 2010, 4:23 AM   #1
most hacker
Newbie
 
Join Date: Jan 2010
Posts: 8
Rep Power: 0 most hacker is on a distinguished road
Serious RichTextBox problem

Hi developers

I'm developing a simple text editor using c#.net … the whole idea is based on using the RichTextBox component provided by the dot net. I'm facing a serious problem that I couldn't solve at all, I tried to look for the solution on codeproject but it seems like all the text editor projects available there have the same problem I have

Simply the problem is :
I apply a text style for some portion of text … for example I apply bold style
Then I select another portion of text and apply italic to it
And here is the problem , when I select both texts and apply underline to them I get them all underlined but I lose both the bold effect and the italic effect

| figured out that the source of the problem is the Font class so I thought it will be good to modify it, but it's locked, they mark this class as sealed class so this is the end

Help me with that guys, I really got tired with this problem
Here is the code for the methods that toggle bold, italic and underline.

Bold

            if (Program.mainForm.ActiveMdiChild.richBox.SelectionFont == null)
                return;

            System.Drawing.FontStyle style = Program.mainForm.ActiveMdiChild.richBox.SelectionFont.Style;

            if (Program.mainForm.ActiveMdiChild.richBox.SelectionFont.Bold)
                style &= ~System.Drawing.FontStyle.Bold;
            else
                style |= System.Drawing.FontStyle.Bold;

            Program.mainForm.ActiveMdiChild.richBox.SelectionFont = new System.Drawing.Font(Program.mainForm.ActiveMdiChild.richBox.SelectionFont, style);



Italic

            if (Program.mainForm.ActiveMdiChild.richBox.SelectionFont == null)
                return;
            System.Drawing.FontStyle style = Program.mainForm.ActiveMdiChild.richBox.SelectionFont.Style;

            if (Program.mainForm.ActiveMdiChild.richBox.SelectionFont.Italic)
                style &= ~System.Drawing.FontStyle.Italic;
            else
                style |= System.Drawing.FontStyle.Italic;
            Program.mainForm.ActiveMdiChild.richBox.SelectionFont = new System.Drawing.Font(Program.mainForm.ActiveMdiChild.richBox.SelectionFont, style);


Underline


            if (Program.mainForm.ActiveMdiChild.richBox.SelectionFont == null)
                return;
            System.Drawing.FontStyle style = Program.mainForm.ActiveMdiChild.richBox.SelectionFont.Style;

            if (Program.mainForm.ActiveMdiChild.richBox.SelectionFont.Underline)
                style &= ~System.Drawing.FontStyle.Underline;
            else
                style |= System.Drawing.FontStyle.Underline;
            Program.mainForm.ActiveMdiChild.richBox.SelectionFont = new System.Drawing.Font(Program.mainForm.ActiveMdiChild.richBox.SelectionFont, style);
most hacker is offline   Reply With Quote
Reply

Bookmarks

Tags
problem, richtextbox

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
An Access records changing and sorting problem Vindicator Visual Basic 2 Jul 8th, 2009 10:10 PM
Problem using isdigit help!! DJ007 C 4 May 5th, 2009 6:29 PM
How to develop problem analysis skills to enable one to decipher a given problem before coding in C++ Man G C++ 7 Apr 16th, 2009 4:49 AM
Problem solving ReggaetonKing Software Design and Algorithms 7 Jan 4th, 2008 1:49 PM
cgi/perl script + IE problem joyceshee Perl 2 Jan 24th, 2006 11:10 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:03 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC