views:

29

answers:

1

I have a Subclass of a BindingSource that just extends it a bit for our special needs, and I would like to support it for the VS2008 Designer.

I have three properties, that I would like to get designer support for, two of them should be set to other Controls on the form, one should be set to a Type.

Displaying them in den Designer as well as setting a default value of null was quite easy, but how do I manage to get VS to select availlable Controls (ideally of desired type only) and or Types ?

Here's the code for the properties so far, any hint is welcome, since I do not know anything over VS-Designer support.

public class BindingSourceEx
    : BindingSource
{
    [DisplayName("DataSourceType")]
    [Description("Sets the type to bind to.")]
    public Type DataSourceType
    {
        get;
        set;
    }

    [DisplayName("BindingNavigator")]
    [DefaultValue(null)]
    [Description("Sets the BindingNavigatorQ1 to use.")]
    public BindingNavigatorEx BindingNavigator
    {
        get;
        set;
    }

    [DisplayName("DataGridView")]
    [DefaultValue(null)]
    [Description("Sets the DataGridViewQ1 to use.")]
    public DataGridViewEx DataGridView
    {
        get;
        set;
    }
}
+1  A: 

The default implementation of the designer already takes care of the BindingNavigator and DataGridView properties. The property grid uses a combobox to let you select the control that matches the control type. You'd have to drop, say, a BindingNavigatorQ1 control on the form to get anything other than None in the combobox.

The Type property is a tougher, you'll need at least a TypeConverter to convert between the Type value and a string. Not so sure this ought to be a designable property, the type you want to bind to surely doesn't yet exist at design time, only at runtime when all the assemblies are compiled.

Hans Passant
Could you provide me a sample code for a TypeConverter like this?
BeowulfOF
I like writing TypeConverters about as much as visits to the dentist. It is only fun after it is done. Especially in this case, rooting for types at design time. It googles well...
Hans Passant