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