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 / .NET Framework / New Users / July 2006

Tip: Looking for answers? Try searching our database.

How do I do this

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Larry Smith - 01 Jul 2006 02:13 GMT
Looking at the ".resx" files produced by the Windows forms designer, I see
nodes like this:

 <data name="MyRadioBtn.Size" type="System.Drawing.Size, System.Drawing">
   <value>94, 21</value>

If you then read the "94, 21" back into your code as a string (exactly as
seen), how do you then deserialize it so it can be converted back into a
"System.Drawing.Size" object (i.e.,there's no "System.Drawing.Size"
constructor that takes this string as an argument but in any case, I assume
the correct way is to reverse the process that created this string in the
first place). Any help would be appreciated. Thanks.
Barry Kelly - 01 Jul 2006 03:38 GMT
Did you include enough groups in the posting list? Gee :)

This is probably most appropriate for framework.windowsforms. It
certainly isn't related to .clr or .csharp, but most stuff in .csharp
isn't strictly related to C# either.

> Looking at the ".resx" files produced by the Windows forms designer, I see
> nodes like this:
[quoted text clipped - 8 lines]
> the correct way is to reverse the process that created this string in the
> first place). Any help would be appreciated. Thanks.

This is done with a TypeConverter. There's a TypeConverterAttribute on
the Point class, and it points to a PointTypeConverter class in
System.Drawing. It's got a ConvertFrom method which does this
transformation. You're supposed to use TypeDescriptor to access the
converter, i.e. with TypeDescriptor.GetConverter(typeof(Point)) etc.

-- Barry

Signature

http://barrkel.blogspot.com/

Larry Smith - 01 Jul 2006 10:14 GMT
> Did you include enough groups in the posting list? Gee :)

Only four groups  - I'm sure you've seen plenty more :)

> This is probably most appropriate for framework.windowsforms. It
> certainly isn't related to .clr or .csharp, but most stuff in .csharp
> isn't strictly related to C# either.

You may be right but there's a lot of overlap also. You therefore have a
better chance of getting the right answer (though you don't want to violate
good NG etiquette by flooding too many groups)

> This is done with a TypeConverter. There's a TypeConverterAttribute on
> the Point class, and it points to a PointTypeConverter class in
> System.Drawing. It's got a ConvertFrom method which does this
> transformation. You're supposed to use TypeDescriptor to access the
> converter, i.e. with TypeDescriptor.GetConverter(typeof(Point)) etc.

And so this proves my point. It's exactly what I needed - thanks very much
(appreciated)
Nicholas Paldino [.NET/C# MVP] - 01 Jul 2006 05:37 GMT
Larry,

   What you want to do is call the static GetConverter method on the
TypeDescriptor class.  Passing the type of System.Drawing.Size to it will
return a TypeConverter instance which you can use to call the
ConvertFromString method on.  This will return a Size structure back to you
which you can then use.

   Hope this helps.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

> Looking at the ".resx" files produced by the Windows forms designer, I see
> nodes like this:
[quoted text clipped - 8 lines]
> assume the correct way is to reverse the process that created this string
> in the first place). Any help would be appreciated. Thanks.
Larry Smith - 01 Jul 2006 10:18 GMT
> What you want to do is call the static GetConverter method on the
> TypeDescriptor class.  Passing the type of System.Drawing.Size to it will
> return a TypeConverter instance which you can use to call the
> ConvertFromString method on.  This will return a Size structure back to
> you which you can then use.

Yes, as Barry Kelly also pointed out. Thanks to both of you (couldn't find
this info after my own initial search)

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.