By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,948 Members | 663 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,948 IT Pros & Developers. It's quick & easy.

Checkbox State Question

P: 16
This is my first post so be easy on me please.

Im using a INI parser to read and write to an ini file. When reading the ini file I have certain parameters set to 1 or 0, which need to be stored to a checkbox variable. Heres a peice of code for reading the ini file.

Expand|Select|Wrap|Line Numbers
  1.             string whispernotify = source.Configs["Settings"].Get("whisper_notify");
  2.  
  3.             if (whispernotify == "1")
  4.             {
  5.                 whisper_notify.Checked = true;
  6.             }
  7.             else
  8.             {
  9.                 whisper_notify.Checked = false;
  10.              }
  11.  
Its working fine but the problem occurs when Im writing back to the ini file. Heres the write back sample:

Expand|Select|Wrap|Line Numbers
  1. source.Configs["Settings"].Set ("whisper_notify", whisper_notify.Checked);
In the ini file its coming up with a "True" or "False" not a 1 or 0 like I need. Ive spent several hours trying different things. Any help pointing me in the right direction would be awesome. Thanks.
Jan 26 '08 #1
Share this Question
Share on Google+
3 Replies


lotus18
100+
P: 866
What language are you using?
Jan 26 '08 #2

daniel aristidou
100+
P: 491
I think this is in the wrong forum...code looks like .net or C
Jan 26 '08 #3

P: 16
its C# visual, but i got it working with this
Expand|Select|Wrap|Line Numbers
  1. if (use_smtp.Checked == true)
  2.             {
  3.                 source.Configs["Settings"].Set("use_smtp","1");
  4.             }
  5.             else
  6.             {
  7.                 source.Configs["Settings"].Set("use_smtp","0");
  8.             }
Jan 27 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.