PC Review


Reply
Thread Tools Rate Thread

Custom design-time control color issues...

 
 
PeterB
Guest
Posts: n/a
 
      14th Dec 2004
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();
}
}


 
Reply With Quote
 
 
 
 
=?Utf-8?B?QWxleCBZYWtobmluIFtNVlBd?=
Guest
Posts: n/a
 
      14th Dec 2004
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();
> }
> }
>
>
>

 
Reply With Quote
 
PeterB
Guest
Posts: n/a
 
      15th Dec 2004
Ah... thanks, that saved me some hair...

I suspect it would be easier to create design time controls in the CF if
you'd done it in the full framework and know all the twist and turns :-)

I also found that the old site doesn't work anymore:
http://msdn.microsoft.com/library/en...asp?frame=true -
NOT WORKING

It has been replaced by a new custom graph control:
http://msdn.microsoft.com/library/de...plications.asp

Another usefull link:
http://www.intelliprog.com/articles/index.html

Adding Icon:
http://groups.google.com/groups?hl=s...mpactframework

Thanks again!

/ 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();
>> }
>> }
>>
>>
>>



 
Reply With Quote
 
PeterB
Guest
Posts: n/a
 
      21st Dec 2004
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();
>> }
>> }
>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
update custom control during Design time --== Alain ==-- Microsoft C# .NET 1 17th Feb 2007 12:15 PM
Persisting Color Properties in Custom Controls at Design Time. =?Utf-8?B?R3V5?= Microsoft C# .NET 5 27th Jan 2004 10:28 AM
Custom ASP control not rendering at design time Chad Microsoft VB .NET 0 10th Nov 2003 03:03 PM
Custom Control's Properties in Design Time Dan Hargrove Microsoft Dot NET Framework Forms 0 7th Nov 2003 04:00 PM
Using Table control in a custom composite control. Control does not render properly in design time. jb_in_marietta@yahoo.com Microsoft ASP .NET 0 1st Jul 2003 10:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:58 AM.