【C#】【Form】 RadioButton / CheckBox / ListBox

■ RadioButton

グループ化

 * 複数のグループを作成する場合は、GroupBoxコントロールまたは Panelコントロール上にRadioButtonを配置
 * グループ化しないと、フォーム上にあるすべてのRadioButtonはすべて同じグループと見なされる
サンプル
if (radioButton1.Checked == true)
    sex = "male";
else
    sex = "female";
参考資料
http://hiros-dot.net/CS2005/Control/RadioButton/RadioButton04.htm

トグルボタン

 * 以下の関連記事を参照。
https://blogs.yahoo.co.jp/dk521123/37905243.html

■ CheckBox

サンプル

string hobby = "";

if (checkBox1.Checked == true)
    hobby += "trip";
if (checkBox2.Checked == true)
    hobby += " reading";
if (checkBox3.Checked == true)
    hobby += " music";
if (checkBox4.Checked == true)
    hobby += " etc";

MessageBox.Show("Hobby : " + hobby, "Info");

■ ListBox

 * 複数項目を一気に削除する場合

サンプル

private void button1_Click(略)
{
     for (int i = 0; i < listBox1.SelectedItem.Count; i++)
     {
           int selectIndex = listBox1.SelectedIndices[i];           
           listBox1.Items.RemoveAt(selectIndex);           
     }
}