471,350 Members | 1,857 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

DefaultValue attribute

Hi,

How do it set the default value of PopupSize?

[DefaultValue(typeof(Size), "{Width=192,Height=168}")]

public Size PopupSize

{

get { return FPopupSize; }

set { FPopupSize = value; }

}

Feb 8 '06 #1
2 3863
tinyabs,

The DefaultValue attribute is used by the designer to set the default
value.

In order to set the value yourself, you have to get the appropriate
class derived from TypeConverter. In order to do this, take the type
specified in the DefaultValue attribute, and look for the TypeConverter
attribute on that type. This should point to another type which has a
TypeConverter which you can then pass the string value to in order to create
the Size instance (which you will have to cast).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"tinyabs" <no****@me.com> wrote in message
news:43******@news.starhub.net.sg...
Hi,

How do it set the default value of PopupSize?

[DefaultValue(typeof(Size), "{Width=192,Height=168}")]

public Size PopupSize

{

get { return FPopupSize; }

set { FPopupSize = value; }

}

Feb 8 '06 #2
You can set the DefaultValue attribute for a property of type Size like
this.

[DefaultValue(typeof(System.Drawing.Size), "192, 168")]
public Size PopupSize
{
...
}

--
Tim Wilson
..NET Compact Framework MVP

"tinyabs" <no****@me.com> wrote in message
news:43******@news.starhub.net.sg...
Hi,

How do it set the default value of PopupSize?

[DefaultValue(typeof(Size), "{Width=192,Height=168}")]

public Size PopupSize

{

get { return FPopupSize; }

set { FPopupSize = value; }

}

Feb 8 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by timtos | last post: by
5 posts views Thread by schneider | last post: by
6 posts views Thread by Meelis Lilbok | last post: by
6 posts views Thread by Peter Hartlén | last post: by
5 posts views Thread by =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.