Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 10th, 2004, 10:34 AM
Authorized User
 
Join Date: Mar 2004
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default Serializable with c#

hey all,
please help me, i want to serialize this attached Form.
how can i do this???
i need a specified code for it,
 it`s very important for me
 thanks you in advanced


public class Form1 : System.Windows.Forms.Form
{
    private System.Windows.Forms.TextBox textBox1;
    private System.Windows.Forms.CheckedListBox checkedListBox1;
    private System.ComponentModel.Container components = null;
public Form1()
    {
    InitializeComponent();
    }

static void Main()
    {
    Application.Run(new Form1());
    }
private void textBox1_TextChanged(object sender, System.EventArgs e)
    {
    }
private void checkedListBox1_ItemCheck(object sender, System.Windows.Forms.ItemCheckEventArgs e)
    {
    }
}

 
Old July 11th, 2004, 05:23 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

What do you mean with "serialize this attached Form"?

What's there to serialize, and what do you need the serialized output for?


Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old July 11th, 2004, 02:47 PM
Authorized User
 
Join Date: Mar 2004
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi
i want to serialize this form.
thats all
thanks koby

 
Old July 11th, 2004, 02:51 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

This is still not very useful. How do you want to serialize it? What do you need it for?
If all you want to do is a simple serialize, copy the text for the form and paste it in a new text document. But I am sure that's not what you're after ;)

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old July 12th, 2004, 01:28 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

I think kobystud needs to have a row content a serialized number from 1 to N!
Am I right?!

Always:),
Hovik Melkomian.
 
Old July 14th, 2004, 07:16 AM
Authorized User
 
Join Date: Mar 2004
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hello
i want to explain my qustion:
what i want to do is to save the state of the controls in the form.
i mean that if i check 2 indices in checklistbox and exit from the program i want to save this state of checklistbox control and when i enter again to this program i want to open the file that i saved before and see the two indices checked.
i hope i explain myself more clearly.
i need a specific answer for this
thank you very much
koby

 
Old July 14th, 2004, 01:35 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Right, I see; that explains a lot.

I don't think it's easy (if possible at all) to truly serialize a form. It's quite a complex object, so it;s a daunting task (unless there is built-in support that I don't know off).

I think the easiest way is to create two methods called LoadState and SaveState (or whatever you see fit). The SaveState gets the information from the form and gets the state from all fields (checkboxes, text boxes etc) that differs from the default and saves it to the registry, or to the an application config / xml file.

The LoadState does the opposite and get the information when the application starts, and restores the form.

Does this help?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: In This World by Moby (Track 2 from the album: 18) What's This?





Similar Threads
Thread Thread Starter Forum Replies Last Post
<Serializable> vs. Inherits ISerializable planoie General .NET 13 May 29th, 2005 10:06 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.