Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I can't explain all that is going on because I only went deep enough to make it work for one specific instance, but...</p> <p>Given a property in a class, one that you wish to display as a drop-down:</p> <pre><code>private String _groupHeader = null; [Category("Display")] [DisplayName("Group Header")] [Description("Any adjacent columns sharing this text will be displayed together as a merged header.")] [DefaultValue("")] [TypeConverter(typeof(GroupHeaderTypeConverter))] public String GroupHeader { get { return _groupHeader; } set { _groupHeader = value; } } </code></pre> <p>You then need a <code>StringConverter</code>:</p> <pre><code>public class GroupHeaderTypeConverter : StringConverter { private static List&lt;String&gt; groupHeaderList = new List&lt;String&gt;(); public override Boolean GetStandardValuesSupported(ITypeDescriptorContext context) { return true; } public override Boolean GetStandardValuesExclusive(ITypeDescriptorContext context) { return false; } public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { return new StandardValuesCollection(groupHeaderList); } public static void SetList(List&lt;String&gt; newList) { groupHeaderList = newList; } } </code></pre> <p>Then, at some point in your code, you have to set the list:</p> <pre><code>private List&lt;String&gt; _groupHeaders = new List&lt;String&gt;(); //add to _groupHeaders GroupHeaderTypeConverter.SetList(_groupHeaders); </code></pre> <p>In my case, I was loading the <code>_groupHeaders</code> list as I was pulling data in from the database.</p> <p>I'm afraid that's as far as I can go...<code>TypeDescriptor</code> is not really my strong suit, but I hope this helps.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload