i made a program in which there is a checkbox which when checked it will change the property of a richtextbox to bold
can anyone please tell me how i can reset it to normal font when i uncheck the checkbox
thanking u
rahul m
Font property of richtextbox
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Niradhip ChakrabortyRank #428 · 5.8K pointsPosted Aug 18, 2009, 3:21 AM EDT
{
if (checkBox1.Checked == true)
{
Font currentFont = richTextBox1.SelectionFont;
FontStyle newFontStyle = (FontStyle)(currentFont.Style | FontStyle.Bold);
richTextBox1.SelectionFont = new Font(currentFont.FontFamily, 7, newFontStyle);
}
else
{
Font currentFont = richTextBox1.SelectionFont;
FontStyle newStyle = FontStyle.Regular;
richTextBox1.SelectionFont = new Font(currentFont.FontFamily, 7, newStyle);
}
}
Ramalingam S24 pointsPosted Aug 24, 2009, 10:29 PM EDT
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
Font font = richTextBox1.Font;
if (checkBox1.Checked)
richTextBox1.Font = new Font(font.FontFamily, font.Size, FontStyle.Bold);
else
richTextBox1.Font = new Font(font.FontFamily, font.Size, FontStyle.Regular);
}