473,414 Members | 1,674 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

how to serialize a form

Hi all,
I need to know if there's a way to serialize a windows form. I included the
[serializable()]/<serializablein the "myclassform" declaration, but I
received an error because the windows.form class isn't marked as serializable.

I can't access the windows.form class so... Any Ideas??

Thank in advance and sorry if I made some mistakes

Cecco
Oct 10 '08 #1
3 3361
Cecco (ITA) wrote:
I need to know if there's a way to serialize a windows form.
(1) Why?
Forms contain lots and /lots/ of data that you probably won't care about
when serializing it.
I included the [serializable()]/<serializablein the "myclassform" declaration, but I
declaration, but Ireceived an error because the windows.form class isn't marked
as serializable.
And there's probably a Good Reason for that (see (1)).

What are you trying to /achieve/?
If you want to save the Form's data then create a class to hold the data
and teach that class how to save (and reload) itself.

Regards,
Phill W.
Oct 10 '08 #2
(1) Why?
Because I need to compare two forms with "equals" method.

My intent is to determine, every time, if a user modified the form, althoug
if he decided to change a data value and then undo the operation.

If I stored data in a struct when the users undo the operation the begining
struct and the newone will be equals.

So, I think, but i'm not sure, if I can have a deep copy of a form at the
begining with "equals" method I can know if someone has modified in some case
the form, also if the datas remain the same.

"Phill W." wrote:
Cecco (ITA) wrote:
I need to know if there's a way to serialize a windows form.

(1) Why?
Forms contain lots and /lots/ of data that you probably won't care about
when serializing it.
I included the [serializable()]/<serializablein the "myclassform" declaration, but I
declaration, but Ireceived an error because the windows.form class isn't marked
as serializable.

And there's probably a Good Reason for that (see (1)).

What are you trying to /achieve/?
If you want to save the Form's data then create a class to hold the data
and teach that class how to save (and reload) itself.

Regards,
Phill W.
Oct 11 '08 #3
Thanks Chuck.

"Chuck" wrote:
I think you might want to look into windows forms databinding in either MSDN
or on Codeproject. You need to to detect changes in the underlying
datasource, not the form itself. For example, datatables have built in
events that fire when column values change.

http://msdn.microsoft.com/en-us/libr...mnchanged.aspx

And built in methods to cancel changes made by the user:

http://msdn.microsoft.com/en-us/libr...ctchanges.aspx

If you are directly binding business objects to the form, then you can build
dirty detection into your classes. If you are using business objects then
also investigate System.ComponentModel.Bindinglist(of T) as it's a real fast
track to getting lists of your business classes bindable.

If you want multiple undo, the strategy is to deepcopy the underlying object
with each edit and push it on a stack. System.Collections.Generic.Stack(Of
T) is great for this.

http://msdn.microsoft.com/en-us/library/3278tedw.aspx

Reverting to a precivious version is as simple as popping the object off the
stack.

Chuck

"Cecco (ITA)" <Ce******@discussions.microsoft.comwrote in message
news:17**********************************@microsof t.com...
(1) Why?
Because I need to compare two forms with "equals" method.

My intent is to determine, every time, if a user modified the form,
althoug
if he decided to change a data value and then undo the operation.

If I stored data in a struct when the users undo the operation the
begining
struct and the newone will be equals.

So, I think, but i'm not sure, if I can have a deep copy of a form at the
begining with "equals" method I can know if someone has modified in some
case
the form, also if the datas remain the same.

"Phill W." wrote:
Cecco (ITA) wrote:

I need to know if there's a way to serialize a windows form.

(1) Why?
Forms contain lots and /lots/ of data that you probably won't care about
when serializing it.

I included the [serializable()]/<serializablein the "myclassform"
declaration, but I
declaration, but Ireceived an error because the windows.form class
isn't marked
as serializable.

And there's probably a Good Reason for that (see (1)).

What are you trying to /achieve/?
If you want to save the Form's data then create a class to hold the data
and teach that class how to save (and reload) itself.

Regards,
Phill W.
Oct 13 '08 #4

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

Similar topics

6
by: sandy | last post by:
With java servlets I can declare complex object-oriented class structures as session variables in a servlet. That means I can have a complex HTML form that submits iteratively back to the server...
5
by: David Sworder | last post by:
Hi, I've created a UserControl-derived class called MyUserControl that is able to persist and subsequently reload its state. It exposes two methods as follows: public void Serialize(Stream...
10
by: Dan | last post by:
All I Am Attempting To Serialize An Object To An XML File. Here Is The Code For That public string SaveNewSurvey( MutualSurveyObject mso_TempObject, int i_JobID ) { string s_RootFileName;...
3
by: MAY | last post by:
Hi, I have a problem about serialize the form controls. I wrote a test program to test serialize a from but fail (->An unhandled exception of type...
2
by: films | last post by:
I understand the concept. Serialization of a class will add all the sub-objects of the class to the stream if there are also serializible. So say I have: class Author {
5
by: objectref | last post by:
Hi to all, let's say i have a form with 2 buttons and 3 textboxes on it. Is there a way to Serialize the form so when i de-Serialize and cast it to a Form, i will get back the original form with...
3
by: Jeff Richardson | last post by:
This is a repost from the InfoPath news group. Hi, I am writing a SharePoint application that works with InfoPath forms. When a user submits a completed InfoPath form to a forms library my code...
2
by: Joe | last post by:
If I serialize an object from with the same class, any fields with the NonSerializableAttribute still get serialized but not if I serialize from outside the class. Why? This is a simple case to...
3
by: VingeFaan | last post by:
Hello. Can I serialize a UserControl directly? By that I mean the entire control itself, not by using extra inner classes or specific logic for each usercontrol? I have 50ish usercontrols which I...
1
by: donrawe42 | last post by:
Hi, I'm trying to submit a for using remote function and Form.serialize, if I render the contents of the parameter in the controller all I see is . I understand that Form.serialize creates the...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.