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
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Ramalingam SPosted Aug 25, 2009, 2:29 AM
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);
}
Niradhip ChakrabortyPosted Aug 18, 2009, 7:21 AM
private void checkBox1_Click(object sender, EventArgs e)
{
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);
}
}