关于Textbox的一个问题
我在textbox中放了几段内容,请问能不能让里面的几个字显示其他的颜色或改变大小。不是全部的
回复 4# coolszy 的帖子
肯定可以的啊,加几句代码就行了 private void radioButton1_CheckedChanged(object sender, System.EventArgs e){
//设置字体为宋体
textBox1.Font=new Font("宋体",textBox1.Font.Size,textBox1.Font.Style);
}
private void radioButton4_CheckedChanged(object sender, System.EventArgs e)
{
//设置字体的大小为12
textBox1.Font=new Font(textBox1.Font.FontFamily,12,textBox1.Font.Style);
}
private void checkBox1_CheckedChanged(object sender, System.EventArgs e)
{
//设置字体的风格为加粗
if(checkBox1.Checked)
textBox1.Font=new Font(textBox1.Font,textBox1.Font.Style|FontStyle.Bold);
else
textBox1.Font=new Font(textBox1.Font,textBox1.Font.Style^FontStyle.Bold);
}
private void checkBox2_CheckedChanged(object sender, System.EventArgs e)
{
//设置字体的风格为倾斜
if(checkBox2.Checked)
textBox1.Font=new Font(textBox1.Font,textBox1.Font.Style|FontStyle.Italic);
else
textBox1.Font=new Font(textBox1.Font,textBox1.Font.Style^FontStyle.Italic);
} 用 RichTextBox 会简单些 好像是需要设置下长度就行了啊 可以实现 只是要写代码 有点繁琐 呵呵
页:
[1]
