开发者

AutoComplete for property grid field

I've a class which I set as source object to a property grid. The values are coming from a value list:

class Person
{
    ...

  开发者_开发百科  [TypeConverter(NationalityStringConverter)]
    public string Nationality
    ...

class NationalityStringConverter: StringConverter
{
    public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
    {
        return true;
    }

    public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
    {
        return true;
    }

    public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
    {
        // return my value collection

Now my question. It it possible to make this list as a suggestion list. In the same way you would set it to a ComboBox like:

comboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
comboBox1.AutoCompleteSource = AutoCompleteSource.ListItems;

Thx 4 answers


Just try to access the Combobox item which is added by the property grid. I don't know if this is feasible, but worth a try ;)


If you create a custom UITypeEditor you should be able to override the behaviour and create your own listbox which you can display when EditValue is called using IWindowsFormsEditorService.DropDownControl. That might give you access to the control you need.

The PropertyGrid also has a ControlAdded event, you might be able to use that to get access to the listbox it creates for editing.

I'm currently wrestling with the PropertyGrid myself so I'm not sure if either of these options gives you what you need, but it may help.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜