Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I have created a user Control which contains Show property can set to True or False and another property Color which Changes Color of my control. But I want that when user will use in Windows Application then user should be able to change these properties. How can I do this ???

C#
public bool Draw1MinuteTicks
    {
        get { return this.bDraw1MinuteTicks; }
        set { this.bDraw1MinuteTicks = value; }
    }
public Color TicksColor
    {
        get { return this.ticksColor; }
        set { this.ticksColor = value; }
    }


I have these properties. when I run and Check my Control it works fine. I run my control and set the Draw1MinuteTicks property to False and stop debugging and is I run again then the Draw1MinuteTicks Property is set to True. So I want that when I run my control and change Draw1MinuteTicks property to False then next time when I run my Control, Draw1MinuteTicks Property should be false only. and the same way TicksColor property to save the coor selected and show the same again when the control will be run.

How to do this ??
Posted
Updated 14-Aug-12 2:56am
v2

Follow the Steps given in this link and the Problem is solved.
http://blog.csharphelper.com/2009/12/09/save-and-restore-settings-in-c.aspx?results=1#SurveyResultsChart[^]

It's Working.
 
Share this answer
 
Folllow this Code Pro Article


Thanks,

Kuthuparakkal
 
Share this answer
 
This is the beauty of app settings...
So your color etc should be assigned using App settings...
Suppose you have a setting called "CurrentColor"
C#
var settings = YourAppNameSpace.Default;
string currentcolor = settings[CurrentColor];
     
somcontrol.BackColor = Color.FromName(currentcolor);


Also save settings as :

C#
var settings = YourAppNameSpace.Default;
string currentcolor = "Blue";
settings["CurrentColor"] = currentcolor;
settings.Save();
 
Share this answer
 
v3
Comments
Ank_ush 14-Aug-12 8:18am    
I didn't got ur code ....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900