public static void StoreControlValue(Control control) { string solutionPath = @"Leden.Net"; if (control.GetType() == typeof(TextBox)) { TextBox c = (TextBox)control; PersistControlValue.SaveLocalAppSetting(solutionPath, c.Name, c.Text); } else if (control.GetType() == typeof(currencyTextBox)) { currencyTextBox c = (currencyTextBox)control; PersistControlValue.SaveLocalAppSetting(solutionPath, c.Name, c.Text); } else if (control.GetType() == typeof(CheckBox)) { CheckBox c = (CheckBox)control; PersistControlValue.SaveLocalAppSetting(solutionPath, c.Name, c.Checked ? "True" : "False"); } else if (control.GetType() == typeof(RadioButton)) { RadioButton c = (RadioButton)control; PersistControlValue.SaveLocalAppSetting(solutionPath, c.Name, c.Checked ? "True" : "False"); } else if (control.GetType() == typeof(Label)) { Label c = (Label)control; PersistControlValue.SaveLocalAppSetting(solutionPath, c.Name, c.Text); } else if (control.GetType() == typeof(NumericUpDown)) { NumericUpDown c = (NumericUpDown)control; PersistControlValue.SaveLocalAppSetting(solutionPath, c.Name, c.Value.ToString()); } else if (control.GetType() == typeof(ComboBox)) { ComboBox c = (ComboBox)control; PersistControlValue.SaveLocalAppSetting(solutionPath, c.Name, c.Text); } else if (control.GetType() == typeof(DateTimePicker)) { DateTimePicker c = (DateTimePicker)control; PersistControlValue.SaveLocalAppSetting(solutionPath, c.Name, c.Text); } else if (control.GetType() == typeof(RichTextBox)) { RichTextBox c = (RichTextBox)control; PersistControlValue.SaveLocalAppSetting(solutionPath, c.Name, c.Text); } }
// public static void ReadControlValue(Control control) // { // if (control.GetType() == typeof(TextBox)) // { // TextBox c = (TextBox)control; // c.Text = PersistControlValue.ReadLocalAppSetting(@"Stand.Net", c.Name); // } // else if (control.GetType() == typeof(CheckBox)) // { // CheckBox c = (CheckBox)control; // c.Checked = PersistControlValue.ReadLocalAppSetting(@"Stand.Net", c.Name) == "True" ? true : false; // } // else if (control.GetType() == typeof(RadioButton)) // { // RadioButton c = (RadioButton)control; // c.Checked = PersistControlValue.ReadLocalAppSetting(@"Stand.Net", c.Name) == "True" ? true : false; // } // else if (control.GetType() == typeof(Label)) // { // Label c = (Label)control; // c.Text = PersistControlValue.ReadLocalAppSetting(@"Stand.Net", c.Name); // } // else if (control.GetType() == typeof(NumericUpDown)) // { // NumericUpDown c = (NumericUpDown)control; // try{c.Value = decimal.Parse(PersistControlValue.ReadLocalAppSetting("BatchFileGenerator", c.Name));} // catch {}; // } // else if (control.GetType() == typeof(ComboBox)) // { // ComboBox c = (ComboBox)control; // c.Text = PersistControlValue.ReadLocalAppSetting("BatchFileGenerator", c.Name); // } // } public static string ReadControlValue(Control control) { string solutionPath = @"Leden.Net"; if (control.GetType() == typeof(TextBox)) { TextBox c = (TextBox)control; c.Text = PersistControlValue.ReadLocalAppSetting(solutionPath, c.Name); return(c.Text); } else if (control.GetType() == typeof(currencyTextBox)) { currencyTextBox c = (currencyTextBox)control; c.Text = PersistControlValue.ReadLocalAppSetting(solutionPath, c.Name); return(c.Text); } else if (control.GetType() == typeof(CheckBox)) { CheckBox c = (CheckBox)control; c.Checked = PersistControlValue.ReadLocalAppSetting(solutionPath, c.Name) == "True" ? true : false; return(c.Checked.ToString()); } else if (control.GetType() == typeof(RadioButton)) { RadioButton c = (RadioButton)control; c.Checked = PersistControlValue.ReadLocalAppSetting(solutionPath, c.Name) == "True" ? true : false; return(c.Checked.ToString()); } else if (control.GetType() == typeof(Label)) { Label c = (Label)control; c.Text = PersistControlValue.ReadLocalAppSetting(solutionPath, c.Name); return(c.Text); } else if (control.GetType() == typeof(NumericUpDown)) { NumericUpDown c = (NumericUpDown)control; try { c.Value = decimal.Parse(PersistControlValue.ReadLocalAppSetting(solutionPath, c.Name)); return(c.Value.ToString()); } catch {}; } else if (control.GetType() == typeof(ComboBox)) { ComboBox c = (ComboBox)control; c.Text = PersistControlValue.ReadLocalAppSetting(solutionPath, c.Name); return(c.Text); } else if (control.GetType() == typeof(DateTimePicker)) { DateTimePicker c = (DateTimePicker)control; c.Text = PersistControlValue.ReadLocalAppSetting(solutionPath, c.Name); } else if (control.GetType() == typeof(RichTextBox)) { RichTextBox c = (RichTextBox)control; c.Text = PersistControlValue.ReadLocalAppSetting(solutionPath, c.Name); } return(string.Empty); }