Click here to Skip to main content
15,911,317 members
Home / Discussions / C#
   

C#

 
AnswerRe: Combobox and "autocompletion" Pin
TMattC26-Mar-15 0:23
TMattC26-Mar-15 0:23 
AnswerRe: Combobox and "autocompletion" Pin
Simon_Whale26-Mar-15 1:29
Simon_Whale26-Mar-15 1:29 
GeneralRe: Combobox and "autocompletion" Pin
TMattC26-Mar-15 4:38
TMattC26-Mar-15 4:38 
Questionadd PDF file to email body not an attachment Pin
sourabkhajuria25-Mar-15 23:49
sourabkhajuria25-Mar-15 23:49 
AnswerRe: add PDF file to email body not an attachment Pin
OriginalGriff25-Mar-15 23:53
mveOriginalGriff25-Mar-15 23:53 
AnswerRe: add PDF file to email body not an attachment Pin
Dave Kreskowiak26-Mar-15 1:27
mveDave Kreskowiak26-Mar-15 1:27 
QuestionUnderstanding Async / Await Pin
zephaneas25-Mar-15 10:07
zephaneas25-Mar-15 10:07 
AnswerRe: Understanding Async / Await Pin
F-ES Sitecore25-Mar-15 12:23
professionalF-ES Sitecore25-Mar-15 12:23 
SuggestionRe: Understanding Async / Await Pin
Richard Deeming26-Mar-15 2:57
mveRichard Deeming26-Mar-15 2:57 
QuestionUse EPPlus to Read 1st Column Of Excel Workbook Into Array (.xlsx) Pin
Hellfire123125-Mar-15 4:42
Hellfire123125-Mar-15 4:42 
AnswerRe: Use EPPlus to Read 1st Column Of Excel Workbook Into Array (.xlsx) Pin
OriginalGriff25-Mar-15 5:25
mveOriginalGriff25-Mar-15 5:25 
QuestionEffective way of writing logs in web service in C#.net Pin
manishchourasia200025-Mar-15 0:19
professionalmanishchourasia200025-Mar-15 0:19 
AnswerRe: Effective way of writing logs in web service in C#.net Pin
Elegantly Wasted25-Mar-15 0:51
Elegantly Wasted25-Mar-15 0:51 
AnswerRe: Effective way of writing logs in web service in C#.net Pin
jschell25-Mar-15 11:28
jschell25-Mar-15 11:28 
QuestionCould not cal the repaint on invalidate Pin
Sarita S24-Mar-15 22:54
Sarita S24-Mar-15 22:54 
AnswerRe: Could not cal the repaint on invalidate Pin
OriginalGriff24-Mar-15 23:06
mveOriginalGriff24-Mar-15 23:06 
AnswerRe: Could not cal the repaint on invalidate Pin
OriginalGriff25-Mar-15 2:19
mveOriginalGriff25-Mar-15 2:19 
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>

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.