比较笨的办法。。遍厉选中的字体,一个个加粗 int l = richTextBox1.SelectionLength; if (l > 0) { for(int i=richTextBox1.SelectionStart;i<l;i++) { richTextBox1.SelectionStart = i; richTextBox1.SelectionLength = i+1; if (richTextBox1.SelectionFont != null) { Font myFont=new Font(richTextBox1.SelectionFont.FontFamily, richTextBox1.SelectionFont.Size,FontStyle.Bold); richTextBox1.SelectionFont=myFont; } } }
不好意思,上面那个有问题int l = richTextBox1.SelectionLength; int s = richTextBox1.SelectionStart; if (l > 0) { for(int i=s;i<s+l;i++) { richTextBox1.Select(i,1); if (richTextBox1.SelectionFont != null) { Font myFont=new Font(richTextBox1.SelectionFont.FontFamily, richTextBox1.SelectionFont.Size,FontStyle.Bold); richTextBox1.SelectionFont=myFont; } } }
int l = richTextBox1.SelectionLength;
if (l > 0)
{
for(int i=richTextBox1.SelectionStart;i<l;i++)
{
richTextBox1.SelectionStart = i;
richTextBox1.SelectionLength = i+1;
if (richTextBox1.SelectionFont != null)
{
Font myFont=new Font(richTextBox1.SelectionFont.FontFamily, richTextBox1.SelectionFont.Size,FontStyle.Bold);
richTextBox1.SelectionFont=myFont;
}
}
}
int s = richTextBox1.SelectionStart;
if (l > 0)
{
for(int i=s;i<s+l;i++)
{
richTextBox1.Select(i,1);
if (richTextBox1.SelectionFont != null)
{
Font myFont=new Font(richTextBox1.SelectionFont.FontFamily, richTextBox1.SelectionFont.Size,FontStyle.Bold);
richTextBox1.SelectionFont=myFont;
}
}
}