Taximaniac

How to save radiobutton state to app settings

Nov 7th, 2018
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1. using System;
  2. using System.Windows.Forms;
  3.  
  4. namespace AppSettingsDemo
  5. {
  6.     public partial class Form1 : Form
  7.     {
  8.         public Form1()
  9.         {
  10.             InitializeComponent();
  11.         }
  12.  
  13.         private void radioButton1_CheckedChanged(object sender, EventArgs e)
  14.         {
  15.             Properties.Settings.Default.RadioButton1State = radioButton1.Checked;
  16.             Properties.Settings.Default.Save();
  17.         }
  18.  
  19.         private void radioButton2_CheckedChanged(object sender, EventArgs e)
  20.         {
  21.             Properties.Settings.Default.RadioButton2State = radioButton2.Checked;
  22.             Properties.Settings.Default.Save();
  23.         }
  24.  
  25.         private void Form1_Load(object sender, EventArgs e)
  26.         {
  27.             Properties.Settings.Default.Reload();
  28.             radioButton1.Checked = Properties.Settings.Default.RadioButton1State;
  29.             radioButton2.Checked = Properties.Settings.Default.RadioButton2State;
  30.  
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment