Click here to Skip to main content
Licence LGPL3
First Posted 15 Sep 2007
Views 11,667
Downloads 74
Bookmarked 14 times

Tolgahan's Form Property Saver

By | 15 Sep 2007 | Article
Tolgahan's Form Property Saver Class Library
Screenshot - image.jpg

Introduction

Sometimes we need to save some properties. This class makes that possible.

The screen shot above is just a simple example. You can easily use this class for more complex applications.

The logic is as follows:

  • Determines the given named property is correct
  • Determines if property return value type is enum
    • If it is an enum, combines it with an integer (so int value type is serializable)
    • If not, determines if it is a serializable, if false, stops executing for current property
  • When your host object (must be a form) is loaded, it checks the registry stream, then sets the properties
  • When the host is closed, it saves the properties to registry

Using the Code

//Using the class        
public Form1()
{
    InitializeComponent();
    //Create new instance of TolgahanPropertySaver onto form1
    //And add some properties to be controlled
    TolgahanFormPropertySaver svr = new TolgahanFormPropertySaver
	(this,"WindowState","Size","Location");
    //Add child controls and properties as string
    svr.AddChild(radioButton1,"Checked");
    //You can use multiple properties at the same time
    svr.AddChild(radioButton2,"Checked","Enabled","Visible");
    svr.AddChild(radioButton3,"Checked");
    svr.AddChild(checkBox1,"Checked");
    svr.AddChild(textBox1,"Text");
}

TolgahanFormPropertySaver Class Diagram

Screenshot - cdg.jpg

Why I Wrote This?

When I was developing an app, it was so difficult to give names, convert types and save with different keys and read the same key with the same things... So I tried to manage all property values from one point. That is the reason I wrote this.

Which Property Types Could Be Used

This class allows only the properties which have ENUM TYPE return values (like FormWindowState, View, Dock, ... etc.), Serializable Struct return values (like Size, Point, .. etc.), Serializable types (like int16, int32, int64, float, bool, string... double, decimal.. etc), Serializable classes (like TreeNode, ListViewItem... etc) and Serializable custom classes (which imported ISerializable interface).

Known Bugs

I still don't know.:) So, if you find any bugs, please report them to me.

Happy coding!

History

  • 15th September, 2007: Initial post

License

This article, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)

About the Author

Tolgahan ALBAYRAK

Software Developer (Senior)

Turkey Turkey

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralThis class is wonder Pinmemberhuohe12310:11 15 Apr '08  
Generalvery cool! Pinmemberqingtianyu93:06 23 Nov '07  
GeneralRe: very cool! PinmemberTolgahan ALBAYRAK12:17 25 Dec '07  
GeneralGreat Pinmemberismailuzumcu12:56 20 Sep '07  
GeneralNice Pinmemberflankerfc8:22 20 Sep '07  
GeneralRe: Nice PinmemberTolgahan ALBAYRAK12:59 20 Sep '07  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120517.1 | Last Updated 15 Sep 2007
Article Copyright 2007 by Tolgahan ALBAYRAK
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid