StringConverter with StandardValuesSupported and Autocompletion

Posted by Marqus on Stack Overflow See other posts from Stack Overflow or by Marqus
Published on 2009-04-28T13:20:25Z Indexed on 2010/04/08 12:23 UTC
Read the original article Hit count: 282

Filed under:
|
|

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

© Stack Overflow or respective owner

Related posts about c#

Related posts about winforms