473,624 Members | 2,510 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Serializing and deserializing form layout

Hi all

Is there a way to serialize the current form's layout to a string or file?

I'll re-phrase - is there an EASY way to do it ;-)

Thanks
Kev
Jun 6 '06 #1
4 1644
Mantorok wrote:
Is there a way to serialize the current form's layout to a string or file?

Kev,

I'm not sure if this will accomplish what you want to do, but code for
the controls and layout of the form will be in the
InitializeCompo nents() method generated by the IDE (assuming you used
the IDE to make the form). If so, you may be able to use reflection to
look at the contents of that method.

Dan Manges
Jun 6 '06 #2
Dan Manges wrote:
I'm not sure if this will accomplish what you want to do, but code for
the controls and layout of the form will be in the
InitializeCompo nents() method generated by the IDE (assuming you used
the IDE to make the form). If so, you may be able to use reflection to
look at the contents of that method.


If you know what the controls on your form are, an easier solution would
be to just write a method to look at each control's location and
serialize it however you want (e.g. "(0,0,20,30 )" for top coordinates
and then size).

Maybe you could give more clarification as to what specifically you
would like to accomplish?

Thanks,

Dan Manges
Jun 6 '06 #3

"Dan Manges" <da***********@ gmail.com> wrote in message
news:xf******** **********@torn ado.ohiordc.rr. com...
Dan Manges wrote:
I'm not sure if this will accomplish what you want to do, but code for
the controls and layout of the form will be in the InitializeCompo nents()
method generated by the IDE (assuming you used the IDE to make the form).
If so, you may be able to use reflection to look at the contents of that
method.


If you know what the controls on your form are, an easier solution would
be to just write a method to look at each control's location and serialize
it however you want (e.g. "(0,0,20,30 )" for top coordinates and then
size).

Maybe you could give more clarification as to what specifically you would
like to accomplish?


I basically have a base-class form and when the form closes and loads I want
it to serialise/deserialize the layout (where possible). My main interests
are size of control.

I would prefer it if the form handled this so that I don't have to code it
for each new control I create.

Kev
Jun 7 '06 #4
Mantorok wrote:
I basically have a base-class form and when the form closes and loads I want
it to serialise/deserialize the layout (where possible). My main interests
are size of control.

I would prefer it if the form handled this so that I don't have to code it
for each new control I create.

Kev


Ah, so you're talking about the size and location of just the form?
(Sorry for the really bad advice before, I misunderstood what you were
trying to do).

I would either use a base class to do this for all your forms, or use a
static method in a helper class that takes the form as an argument.

Example using a static method (can easily be adjusted to use a base class):

public static void RememberFormSiz e(Form myForm)
{
/* load height and width from where you saved it last and adjust
the form accordingly */
myForm.Resize += new EventHandler(my Form_Resize);
}

static void myForm_Resize(o bject sender, EventArgs e)
{
Form theForm = (Form)sender;
int height = theForm.Size.He ight;
int width = theForm.Size.Wi dth;
/* save height and width in a file, database, or whatever works for
your application */
}

I think typecasting the sender in the myForm_Resize method to a Form
should be okay. Somebody please correct me if it's not.

Hopefully this helps you, sorry again for the bad advice before.

Dan Manges
Jun 7 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3165
by: Don McNamara | last post by:
Hi, I've hit quite a strange problem with XmlSerializer on my W2K3 server. When I serialize/deserialize using an exe on my local computer (XP), everything works fine. When I put the code out on the server (W2K3) it throws an exception. It only seems to happen when serializing/deserializing _arrays_ of a type. If I just serialize/deserialize one instance, it works fine. The exception I get is: (sorry for the word wrapping.)...
5
4787
by: Alfonso Morra | last post by:
Hi, I am writing a messaging library which will allow me to send a generic message structure with custom "payloads". In many cases, a message must store a non-linear data structure (i.e. "payload") using pointers. Examples of these are binary trees, hash tables etc. Thus, the message itself contains only a pointer to the actual data. When the message is sent to the same processor, these pointers point to the original locations, which...
2
3091
by: Earl Teigrob | last post by:
I am saving and restoring value types such as Int32, DateTime and Boolean in strings. I was wondering if there is a mechanism build into .NET for serializing and deserializing these to string format. I can, of course, serialize a class to a file, either binary or XML, but this is not what I am looking for. Currently I am using ToString() or Convert.xxx to do this, but thought that if there was a true serializer, deserializer, that would be...
7
2818
by: fjlaga | last post by:
I have written an Office Add-in for Excel using VB.NET and the .NET 1.1 Framework (I have Visual Studio 2003 .NET ). All works great. I want to add a User Settings/Prefereneces dialog and allow the user to specify some settings and I need to persist these settings between runs. I made a serializable class which uses the BinaryFormatter to serialize/deserialize the setttings. Serialization works great. However, when I try to...
0
8614
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8330
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8471
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7153
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4075
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4167
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2603
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1474
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.