在下面的代码中如果我在字体没有改变 Font
之前设置。必须设置在. 这是什么怪癖吗?Rtf
Font
Rtf
RichTextBox
[TestMethod]
public void FontProblemTest()
{
Form f = new Form();
RichTextBox brtb = new RichTextBox();
brtb.Width = 800;
brtb.Height = 500;
brtb.Font = new System.Drawing.Font(new System.Drawing.FontFamily("Courier New"), 8.25F, System.Drawing.FontStyle.Regular);//font set here has no effect
brtb.Rtf = @"{\rtf1\ansi\deff0{\fonttbl{\f0\fnil Arial;}{\f1\fnil\fcharset0 Courier New;}}" +
@"{\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\trowd\trgaph10\trleft-10\trpaddl10\trpaddr10\trpaddfl3\trpaddfr3" +
@"\cellx1140\cellx3740\cellx7340\pard\intbl\lang1033\f0\fs20\cell Whole Chart, Low to High\cell Most Recent (7/14/2002 10:17 AM)\cell\row" +
@"}";
//brtb.Font = new System.Drawing.Font(new System.Drawing.FontFamily("Courier New"), 8.25F, System.Drawing.FontStyle.Regular);//font must be set after rtf.
f.Controls.Add(brtb);
f.Width = 1000;
f.Height = 800;
f.ShowDialog();
}