public void ReadFromIni(I3Ini aIni, string sectionName) { if (!aIni.GetBool(sectionName, "HasSaved", false)) { return; } try { string st = aIni.GetString(sectionName, "SearchType", I3SearchType.stNone.ToString()); searchType = (I3SearchType)Enum.Parse(typeof(I3SearchType), st); } catch { searchType = I3SearchType.stNone; } string1 = aIni.GetString(sectionName, "String1", ""); num1 = aIni.GetFloat(sectionName, "Num1", 0); num2 = aIni.GetFloat(sectionName, "Num2", 0); date1 = aIni.GetTime(sectionName, "Date1", DateTime.MaxValue); date2 = aIni.GetTime(sectionName, "Date2", DateTime.MaxValue); RefreshResult(); }
/// <summary> /// 从ini读取StringList /// </summary> /// <param name="aFileName"></param> /// <param name="aSectionName"></param> /// <param name="comboBox"></param> public static void ReadListFromIni(string aFileName, string aSectionName, ComboBox comboBox) { using (I3Ini ini = new I3Ini()) { ini.FileName = aFileName; ini.Active = true; if (!ini.Active) { return; } int count = ini.GetInt(aSectionName, "count", 0); comboBox.Items.Clear(); for (int i = 0; i < count; i++) { comboBox.Items.Add(ini.GetString(aSectionName, i.ToString(), "")); } } }