public override void LoadCurrentValue(DuplicatingIni configIni) { var entry = configIni.GetValue(SectionName, PropertyName); int index = -1; bool indexFound = false; if (entry != null) { foreach (IniPropertyEnumValue enumval in Choices) { index++; if (enumval.IniValue.Equals(entry.Value, StringComparison.InvariantCultureIgnoreCase)) { indexFound = true; break; } } if (!indexFound) { //user has their own item IniPropertyEnumValue useritem = new IniPropertyEnumValue(); useritem.FriendlyName = useritem.IniValue = entry.Value; Choices.Add(useritem); CurrentSelectedIndex = Choices.Count - 1; } else { CurrentSelectedIndex = index; } } }
public override void LoadCurrentValue(IniFile configIni) { string val = configIni.Read(PropertyName, SectionName); int index = -1; bool indexFound = false; foreach (IniPropertyEnumValue enumval in Choices) { index++; if (enumval.IniValue.Equals(val, StringComparison.InvariantCultureIgnoreCase)) { indexFound = true; break; } } if (!indexFound) { //user has their own item IniPropertyEnumValue useritem = new IniPropertyEnumValue(); useritem.FriendlyName = useritem.IniValue = val; Choices.Add(useritem); CurrentSelectedIndex = Choices.Count - 1; } else { CurrentSelectedIndex = index; } }