Click here to Skip to main content
15,889,542 members
Home / Discussions / C#
   

C#

 
QuestionScheduler without using timer class in c# Pin
Member 1138787724-Mar-15 19:48
Member 1138787724-Mar-15 19:48 
AnswerRe: Scheduler without using timer class in c# Pin
Pete O'Hanlon24-Mar-15 20:13
mvePete O'Hanlon24-Mar-15 20:13 
QuestionSingleton vs Whatever Else Quandary Pin
Z.C.M.24-Mar-15 16:58
professionalZ.C.M.24-Mar-15 16:58 
AnswerRe: Singleton vs Whatever Else Quandary Pin
Mycroft Holmes24-Mar-15 17:09
professionalMycroft Holmes24-Mar-15 17:09 
AnswerRe: Singleton vs Whatever Else Quandary Pin
Pete O'Hanlon24-Mar-15 19:32
mvePete O'Hanlon24-Mar-15 19:32 
GeneralRe: Singleton vs Whatever Else Quandary Pin
Z.C.M.25-Mar-15 4:00
professionalZ.C.M.25-Mar-15 4:00 
AnswerRe: Singleton vs Whatever Else Quandary Pin
jschell25-Mar-15 11:34
jschell25-Mar-15 11:34 
QuestionWhat is wrong with the structure of this code? Pin
Member 1147801824-Mar-15 0:25
Member 1147801824-Mar-15 0:25 
I am currently working on some settings for an application, but I have an annoying problem. I decided to store the settings in a .xml file and then read the values when loading the settings etc. Whenever the settings form is opened, the application will check the values stored in the .xml file and check a specific value is set to "true" or "false". I have a combobox and when you check this combobox, the application will ask you where you want to save the logs using FolderBrowserDialog. If you choose a folder then it will close, you can click the "Save" button and it will work. If you click on "Cancel" then the FolderBrowserDialog window will close and the checkbox will be unchecked automatically. The problem I am facing is that if you check the combobox, click the save button (which changes the value from "false" to "true"), exit the settings and then open the settings form then it will open the FolderBrowserDialog again. This is because the element, which in this case is called "<save_logs>", is set to true.

So my question to you is how can I fix this?

Combobox code
C#
private void Save_log_CheckedChanged(object sender, EventArgs e)
       {
           // Check if Save_log is checked and if the Save_logs_path element has the default value in Settings.xml.
           if (Save_logs_checkbox.Checked && path_selected == false)
           {
               Save_logs_combobox.Enabled = true;

               // Use the FolderBrowserDialog control to ask the user to specify which folder the logs should be saved in.
               var fbd = new FolderBrowserDialog();

               // Switch statement for checking which button was pressed in the FolderBrowserDialog window.
               switch (fbd.ShowDialog())
               {
                   case DialogResult.OK:
                       XmlHandler.Edit("//Other/Save_logs_path", fbd.SelectedPath);
                       path_selected = true;
                       break;

                   case DialogResult.Cancel:
                       Save_logs_checkbox.Checked = false;
                       Save_logs_combobox.Enabled = false;
                       break;
               }
           }
           else if (Save_logs_checkbox.Checked && path_selected)
               Save_logs_combobox.Enabled = true;
           else
               Save_logs_combobox.Enabled = false;
       }


XML
C#
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Settings>
  <Shortcuts>
    <Copy_shortcuts>
      <Shortcut_1>CTRL+ALT+1</Shortcut_1>
      <Shortcut_2>CTRL+ALT+2</Shortcut_2>
      <Shortcut_3>CTRL+ALT+3</Shortcut_3>
      <Shortcut_4>CTRL+ALT+4</Shortcut_4>
      <Shortcut_5>CTRL+ALT+5</Shortcut_5>
      <Shortcut_6>CTRL+ALT+6</Shortcut_6>
      <Shortcut_7>CTRL+ALT+7</Shortcut_7>
      <Shortcut_8>CTRL+ALT+8</Shortcut_8>
      <Shortcut_9>CTRL+ALT+9</Shortcut_9>
      <Shortcut_10>CTRL+ALT+10</Shortcut_10>
    </Copy_shortcuts>
    <Paste_shortcuts>
      <Shortcut_1>CTRL+SHIFT+1</Shortcut_1>
      <Shortcut_2>CTRL+SHIFT+2</Shortcut_2>
      <Shortcut_3>CTRL+SHIFT+3</Shortcut_3>
      <Shortcut_4>CTRL+SHIFT+4</Shortcut_4>
      <Shortcut_5>CTRL+SHIFT+5</Shortcut_5>
      <Shortcut_6>CTRL+SHIFT+6</Shortcut_6>
      <Shortcut_7>CTRL+SHIFT+7</Shortcut_7>
      <Shortcut_8>CTRL+SHIFT+8</Shortcut_8>
      <Shortcut_9>CTRL+SHIFT+9</Shortcut_9>
      <Shortcut_10>CTRL+SHIFT+10</Shortcut_10>
    </Paste_shortcuts>
    <Other>
      <Windows_start>false</Windows_start>
      <Notifications>true</Notifications>
      <Save_logs>false</Save_logs>
      <Save_logs_path>C:\Users\UserHere\Desktop\Folder</Save_logs_path>
      <Save_logs_as>txt</Save_logs_as>
    </Other>
  </Shortcuts>
</Settings>

AnswerRe: What is wrong with the structure of this code? Pin
Ron Nicholson24-Mar-15 3:20
professionalRon Nicholson24-Mar-15 3:20 
GeneralRe: What is wrong with the structure of this code? Pin
Dave Kreskowiak24-Mar-15 3:48
mveDave Kreskowiak24-Mar-15 3:48 
GeneralRe: What is wrong with the structure of this code? Pin
Member 1147801824-Mar-15 11:06
Member 1147801824-Mar-15 11:06 
GeneralRe: What is wrong with the structure of this code? Pin
Ron Nicholson24-Mar-15 11:43
professionalRon Nicholson24-Mar-15 11:43 
AnswerRe: What is wrong with the structure of this code? Pin
Gerry Schmitz24-Mar-15 12:14
mveGerry Schmitz24-Mar-15 12:14 
Questionc# Pin
Member 1133602722-Mar-15 8:40
Member 1133602722-Mar-15 8:40 
AnswerRe: c# Pin
Afzaal Ahmad Zeeshan22-Mar-15 8:53
professionalAfzaal Ahmad Zeeshan22-Mar-15 8:53 
Questionusing usage (IDisposable) Pin
TMattC22-Mar-15 6:15
TMattC22-Mar-15 6:15 
AnswerRe: using usage (IDisposable) Pin
phil.o22-Mar-15 6:38
professionalphil.o22-Mar-15 6:38 
AnswerRe: using usage (IDisposable) Pin
OriginalGriff22-Mar-15 6:41
mveOriginalGriff22-Mar-15 6:41 
AnswerRe: using usage (IDisposable) Pin
manchanx22-Mar-15 6:54
professionalmanchanx22-Mar-15 6:54 
AnswerRe: using usage (IDisposable) Pin
jschell22-Mar-15 9:40
jschell22-Mar-15 9:40 
AnswerRe: using usage (IDisposable) Pin
TMattC22-Mar-15 9:49
TMattC22-Mar-15 9:49 
AnswerMessage Closed Pin
22-Mar-15 14:22
mveGerry Schmitz22-Mar-15 14:22 
GeneralRe: using usage (IDisposable) Pin
Richard Deeming23-Mar-15 3:17
mveRichard Deeming23-Mar-15 3:17 
GeneralMessage Closed Pin
23-Mar-15 4:21
mveGerry Schmitz23-Mar-15 4:21 
GeneralRe: using usage (IDisposable) Pin
Richard Deeming23-Mar-15 4:26
mveRichard Deeming23-Mar-15 4:26 

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

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