Вам необходимо иметь пользовательский UITypeEditor.
public class CultureInfoEditor : UITypeEditor
{
private static List<CultureInfo> nclacCultureInfos = new List<CultureInfo>()
{
CultureInfo.GetCultureInfo("ru-RU"),
CultureInfo.GetCultureInfo("en-US")
};
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
return UITypeEditorEditStyle.DropDown;
}
IWindowsFormsEditorService currentService;
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
currentService = (IWindowsFormsEditorService)
provider.GetService(typeof(IWindowsFormsEditorService));
ListBox cultures = new ListBox();
cultures.Items.Add(nclacCultureInfos[0].DisplayName);
cultures.Items.Add(nclacCultureInfos[1].DisplayName);
cultures.Text = ((CultureInfo)(context.Instance as Settings)["CurentLanguage"]).DisplayName;
cultures.Dock = DockStyle.Top;
cultures.MouseClick += cultures_MouseClick;
currentService.DropDownControl(cultures);
return nclacCultureInfos[cultures.SelectedIndex];
}
void cultures_MouseClick(object sender, MouseEventArgs e)
{
currentService.CloseDropDown();
}
}
И вы должны указать этот редактор для нашего свойства:
[global::System.Configuration.UserScopedSetting()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
[Category("Main Settings")]
[DisplayName("Default Language")]
[Editor(typeof(CultureInfoEditor), typeof(UITypeEditor))] // THIS LINE HAS BEEN ADDED
public CultureInfo CurentLanguage
{
get
{
return ((CultureInfo)(this["CurentLanguage"]));
}
set
{
this["CurentLanguage"] = value;
}
}
Надеюсь, это поможет.