views:

252

answers:

1

I want to develop a StringConverter with standard values, which after attaching it to a PropertyGrid will act like comboBox with autocompletion. The example below will give me a comboBox, but without the autocompletion - user have to expand it and choose manually one of the items. Is there a way to allow user to type the beginning of one of the options, so the combobox will automatically select the matching one?

   public class ConverterSample : System.ComponentModel.StringConverter
   {        
      public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
      {
         //true means show a combobox
         return true;
      }

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


      public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
      {         
         return new StandardValuesCollection(new List<string>(){"Stack", "overflow", "rules");

  }

List returned by GetStandardValues has to be dynamic, so I can't use any enum there. I took above example from: http://www.codeproject.com/KB/cpp/dropdownproperties.aspx

A: 

I'm no expert but it sounds like you need a UITypeEditor. An example can be found here: http://www.codeproject.com/Messages/1020184/Re-combobox-values.aspx

Steve Dunn