Hello again!
I now have the same problem with the BackgroundImage property. I am
inheriting from Control, which also has a BackgroundImage property in the
full framework so I need to add an override in the design version of the
property. My suggestion is:
/// <summary>
/// Property for the background image to be drawn behind the button text.
/// </summary>
#if DESIGN
public override Image BackgroundImage
#else
public Image BackgroundImage
#endif
{
get
{
return this.m_bmpBackgroundImage;
}
set
{
this.m_bmpBackgroundImage = value;
this.Invalidate();
}
}
#if DESIGN
public bool ShouldSerializeBackgroundImage()
{
return (m_bmpBackgroundImage != null);
}
// public override void ResetBackgroundImage()
// {
// BackgroundImage = null;
// }
#endif
However this doesn't seem to work, or atleast I don't get it to work... are
there any special circumstances to think about when it comes to the
BackgroundImage property??
thanks,
Peter
"Alex Yakhnin [MVP]" <(E-Mail Removed)> skrev i meddelandet
news:18830FCC-9322-429D-AB66-(E-Mail Removed)...
> Try to add the follwoing:
>
> #if DESIGN
> public bool ShouldSerializeBackColor()
> {
> return (backColor != Color.Empty);
> }
> public override void ResetBackColor()
> {
> BackColor = Color.Empty;
> }
> #endif
>
> HTH... Alex
> --
> Alex Yakhnin, .NET CF MVP
> www.intelliprog.com
> www.opennetcf.org
>
> "PeterB" wrote:
>
>> Hello everyone!
>>
>> I am creating a custom label that could be used in VS design time. I am
>> inheriting from Control and do all of my drawing myself. I can add a
>> label
>> to a design form in VS, resize it, change colors (back and fore), change
>> the
>> font and of course the text. It all looks fine on the VS IDE design form.
>>
>> The problem is that the code, that reflect the color/font changes, is not
>> applied to the InitializeComponent method, so if if I close VS and open
>> it
>> again, the label is reset to it's original color/font values.
>>
>> Any help here would be greatly appreciated!
>>
>> / Peter
>>
>>
>> Some more info:
>> I am overriding ForeColor and BackColor
>>
>> In my control I use the following members to save the color information:
>> private Color m_backColor = Color.White; //Color.Empty;
>> private Color m_foreColor = Color.Black;
>>
>> I then have 2 overridden properties (1 shown)
>> /// <summary>
>> /// Gets or sets the background color for the control.
>> /// </summary>
>> #if DESIGN
>> [
>> Category("Appearance"),
>> Description("The background color used to display text in the SIB
>> control.")
>> ]
>> #endif
>> public override Color BackColor
>> {
>> get
>> {
>> if ((m_backColor == Color.Empty) && (this.Parent != null))
>> {
>> return Parent.BackColor;
>> }
>> return m_backColor;
>> }
>> set
>> {
>> m_backColor = value;
>> this.Invalidate();
>> }
>> }
>>
>>
>>