我正在構建使用文件來配置某些字體的應用程序。它是這樣的:值不符合預期
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