TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mayank Jani
NA
477
77.4k
RichTextBox format with Bold, Underline & Font the same word
Jul 14 2018 8:42 AM
Dear Members,
I am working on a RichTextBox as letter printing format. I can format the letter with font, bold, italics etc. my problem is when I select a word or a string to apply bold and underline, it can apply only either bold or underline. after formating a paragraph, when I choose a word and select bold, then the word turns bold but the font gets changed!!
I use mouse right click to open menu and select option that I want to apply. Here is my code...
//For bold and italics
private void richTxtLetter_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Right)
{
ContextMenu RightClick = new System.Windows.Forms.ContextMenu();
MenuItem MIbold = new MenuItem("Bold");
MIbold.Click += new EventHandler(BoldAction);
RightClick.MenuItems.Add(MIbold);
MenuItem MIitalics = new MenuItem("Italics");
MIitalics.Click += new EventHandler(ItalicsAction);
RightClick.MenuItems.Add(MIitalics);
richTxtLetter.ContextMenu = RightClick;
}
}
//Calling ...
void BoldAction(object sender, EventArgs e)
{
richTxtLetter.SelectionFont = new Font(richTxtLetter.Font, FontStyle.Bold);
}
void ItalicsAction(object sender, EventArgs e)
{
richTxtLetter.SelectionFont = new Font(richTxtLetter.Font, FontStyle.Italic);
}
Please let me know if there is any option that I can use bold and italics, or bold and underline to same word or string or paragraph. the font should remain the same as the whole letter created of.
Thank You
Mayank Jani
Reply
Answers (
7
)
c# coding in webform
Find maximum valid time that can be displayed C#