Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace WindowsFormsApplication1
- {
- public partial class Form1 : Form
- {
- private int BitPosition = 1;
- private int BitMask = 0;
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- foreach(RadioButton RadioButton in groupBox1.Controls.OfType<RadioButton>())
- { // add RadioButtonSelected setting to this project
- BitMask = Properties.Settings.Default.RadioButtonSelected;
- RadioButton.Tag = BitPosition;
- RadioButton.Checked = (BitMask & Convert.ToInt32(RadioButton.Tag)) == Convert.ToInt32(RadioButton.Tag);
- BitPosition *= 2;
- }
- }
- private void Form1_FormClosing(object sender, FormClosingEventArgs e)
- {
- RadioButton checkedRadioButton = groupBox1.Controls.OfType<RadioButton>().FirstOrDefault(r => r.Checked);
- BitMask = 0;
- BitMask = BitMask ^ Convert.ToInt32(checkedRadioButton.Tag);
- Properties.Settings.Default.RadioButtonSelected = BitMask;
- Properties.Settings.Default.Save();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement