简体   繁体   English

具有StandardValuesSupported和自动补全功能的StringConverter

[英]StringConverter with StandardValuesSupported and Autocompletion

I want to develop a StringConverter with standard values, which after attaching it to a PropertyGrid will act like comboBox with autocompletion. 我想开发一个具有标准值的StringConverter,将其附加到PropertyGrid后将像具有自动补全功能的comboBox一样。 The example below will give me a comboBox, but without the autocompletion - user have to expand it and choose manually one of the items. 下面的示例为我提供了一个comboBox,但是没有自动补全功能-用户必须展开它并手动选择其中一项。 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. GetStandardValues返回的列表必须是动态的,因此我不能在那里使用任何枚举。 I took above example from: http://www.codeproject.com/KB/cpp/dropdownproperties.aspx 我从以下示例中获取了以下示例: http : //www.codeproject.com/KB/cpp/dropdownproperties.aspx

I'm no expert but it sounds like you need a UITypeEditor. 我不是专家,但听起来您需要UITypeEditor。 An example can be found here: http://www.codeproject.com/Messages/1020184/Re-combobox-values.aspx 可以在这里找到示例: http : //www.codeproject.com/Messages/1020184/Re-combobox-values.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM