Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Design Time / December 2004

Tip: Looking for answers? Try searching our database.

DefaultValue(typeof(Padding), "??"

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Juan Ignacio Gelos - 15 Dec 2004 23:53 GMT
Hi all,

I tried this one but doesn't seem to work. I looked into the IL for Padding
and PaddingConverter but doesn't seem to have a CreateInstance(string)... is
it possible at all to specify a DefaultValue for it? Any workarounds?

[DefaultValue(typeof(Padding), "{Left=2,Top=2,Right=2,Bottom=1}")]

Thanks,
Juan
joeycalisay - 16 Dec 2004 01:21 GMT
I can't see where your Padding and PaddingConverter is declared.  Are you
talking about DockPadding?  For complex types, you should be using
ShouldSerialize<PropertyName> and Reset<PropertyName> methods...

> Hi all,
>
[quoted text clipped - 6 lines]
> Thanks,
> Juan
Juan Ignacio Gelos - 16 Dec 2004 17:44 GMT
Thanks. Padding is a .NET 2 class, PaddingConverter is its (internal)
TypeConverter.

> I can't see where your Padding and PaddingConverter is declared.  Are you
> talking about DockPadding?  For complex types, you should be using
[quoted text clipped - 12 lines]
> > Thanks,
> > Juan
joeycalisay - 17 Dec 2004 01:59 GMT
Whidbey again, no time to test it yet.  Anyway, i've read that they're
changing the shouldserialize<propertyname> method to
shouldpersist<propertyname> in 2.0

> Thanks. Padding is a .NET 2 class, PaddingConverter is its (internal)
> TypeConverter.
[quoted text clipped - 16 lines]
> > > Thanks,
> > > Juan
Juan Ignacio Gelos - 17 Dec 2004 09:23 GMT
Joey,

   Can you elaborate on the signature of the Reset<PropertyName> methods I
should implement? Also, any url to a sample or documentation would be
appreciated. The following doesn't seem to work:

[Category("Layout")]
[DefaultValue(typeof(Padding), "1, 3, 3, 0")]
public new Padding Padding
{
   get
   {
       return padding;
   }
   set
   {
       padding = value;
       base.Padding = padding;
   }
}
private Padding padding = new Padding(1, 3, 3, 0);

public void ResetPadding()
{
   padding = new Padding(1 3, 3, 0);
}

Regards,
Juan

> I can't see where your Padding and PaddingConverter is declared.  Are you
> talking about DockPadding?  For complex types, you should be using
[quoted text clipped - 12 lines]
> > Thanks,
> > Juan
Francois Miousse - 17 Dec 2004 15:49 GMT
I was having the same problem, and I found the solution.
Remove [DefaultValue(...)] and add ShouldSerializePadding.

Try this:

[Category("Layout")]
public new Padding Padding
{
    get
    {
        return padding;
    }
    set
    {
        padding = value;
        base.Padding = padding;
    }
}
private Padding padding = new Padding(1, 3, 3, 0);

public void ResetPadding()
{
    padding = new Padding(1 3, 3, 0);
}

public bool ShouldSerializeMargin()
{
   return padding != new Padding( 1 3, 3, 0 );
}
Juan Ignacio Gelos - 17 Dec 2004 20:05 GMT
It worked!
Thanks again, Francois & Joey

> I was having the same problem, and I found the solution.
> Remove [DefaultValue(...)] and add ShouldSerializePadding.
[quoted text clipped - 25 lines]
>     return padding != new Padding( 1 3, 3, 0 );
> }
joeycalisay - 20 Dec 2004 01:35 GMT
Actually, documentation says use one or the other.  For the documentation,
try this one, it helped me a lot:

http://www.awprofessional.com/articles/printerfriendly.asp?p=169528

> It worked!
> Thanks again, Francois & Joey
[quoted text clipped - 28 lines]
> >     return padding != new Padding( 1 3, 3, 0 );
> > }

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.