Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
665
How can I set the DefaultValueAttribute for an Appearance?
posted

I have a control called 'PhCombo' which inherits from 'UltraCombo'. In the constructor of PhGrid I initialise some Appearance properties, in particular the ImageHAlign, ImageVAlign and Image properties. The inherited control works fine but when I delve into the Designer code I notice that the ImageHAlign, ImageVAlign and Image properties are also being set in the InitializeComponent code of forms which contain the PhCombo control.

I would like to set the modified ImageHAlign, ImageVAlign and Image properties as the DefaultValues for the PhCombo.

The code below is an example of what I would like to do but obviously doesn't work:

[DefaultValue(typeof(Appearance), "CustomAppearance")]
public new Appearance
{
    get { return base.Appearance; }
    set { base.Appearance = value; }
}

Thanks
Paul

Parents
No Data
Reply
  • 469350
    Offline posted

    hi Paul,

    I don't think you can do that. At least not the way you have it here. In order to specify different default for properties on the Appearance object, you would have to derive your own class from Appearance and override the ShouldSerializeXXX methods on that class. I'm not entirely sure that would work, though.

    You would also have to deal with the ShouldSerialize method on the Appearance object, itself. I'm not sure if that method is even overridable, although if it's not, it probably should be.

    In addition, you will need to handle all of the ResetXXX methods and the Reset on the Appearance itself.

Children
No Data