![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Newbie
Join Date: Jan 2010
Posts: 8
Rep Power: 0
![]() |
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); |
|
|
|
![]() |
| Bookmarks |
| Tags |
| problem, richtextbox |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
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 |