Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello all,

I've been looking around but did not find an appropriate answer.

Is it possible to do the following:

I have three checkboxes on a Winform.

Now I create two settings files.

In settings1, all three checkboxes' checked state is TRUE by default.
In settings2, the default states are FALSE for each checkbox.

Is there any way to either apply setting1 or setting2 at runtime or at user interaction (button click, ...)?
Posted
Comments
Michiel du Toit 2-Jan-13 7:54am    
Hi Dennis,

You can use Environment.UserName to see which user is currently logged on to Windows.

You can use the Form's Load event to execute code when the form opens up.

Loading the settings from the file will depend on the type of file - if it is a text file you can use something like:
var myfile = new StreamReader(new FileStream("file.txt", FileAccess.Read));
myfile.ReadLine();

More details are necessary if you want more help.
[no name] 2-Jan-13 13:50pm    
Hello Michiel, I use the method described here: http://msdn.microsoft.com/en-us/library/k4s6c3a0.aspx - is there any way to have multiple configurations?

I am unable clearly understand your question..

But if you need to Check a CheckBox in runtime use :

C#
Checkbox1.Enabled = true;
Checkbox2.Enabled = true;
Checkbox3.Enabled = true;
 
Share this answer
 
Comments
[no name] 2-Jan-13 9:49am    
Mohammed, my question is about user settings, not about how to set the checked state of a checkbox. Thanks anyways :)
Hi Friend Little Bit Confusion but may it helps you

if(Setting1== true) // something that can make Settings condition true
{
Checkbox1.Enabled = true;
Checkbox2.Enabled = true;
Checkbox3.Enabled = true;
MessageBox.show("Setting1 Successfully Applied ");
}
if(Setting2==true)
{
Checkbox1.Enabled = false;
Checkbox2.Enabled = false;
Checkbox3.Enabled = false;
MessageBox.show("Setting2 Successfully Applied ");
}
there is many Events e.g(Button, Load, Check_Change etc) that can help to run these conditions
thanks
 
Share this answer
 
Comments
[no name] 2-Jan-13 10:51am    
Sorry, but you also don't get the point :) Am I so unclear? It's about application and user settings as described here: http://msdn.microsoft.com/en-us/library/k4s6c3a0.aspx

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