我正在构建使用文件来配置某些字体的应用程序。它是这样的:值不符合预期
Font = Verdana
Size = 12
Style = Bold
我的代码是这样的:
openDialog.ShowDialog();
string file = openDialog.FileName;
StreamReader reader = new StreamReader(file);
while (reader.Peek() <= 0)
{
string line = reader.ReadLine();
string[] data = Split(new[] { '=' });
// property is in data[0]
// value is in data[1]
TextFont = data[1];
TextSize = data[3];
TextSt = data[5];
}
reader.Close();
reader.Dispose();
,并用它是这样的:
textBox1.Font = new System.Drawing.Font(TextFont, 12F, FontStyle.Bold);
但是,当我执行它,我得到这个错误:
ArgumentException
Value does not fall within the expected
然后我有两个问题:
- 我该如何解决这个问题?
- 如何使用浮点数来代替
TextSize
而不是Font
方法中的浮点数?
谢谢。
谢谢你回答我的第二个问题李。 – 2009-11-12 21:00:43