1
我想獲取.(name)
- 已更改的複選框的特性?
我只需要在Messagebox上顯示一個小例子。如何獲取已更改的複選框項目的對象名稱?
小片段:
namespace Checkboxes
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.chkCar.Name = "chkCar";
this.chkCar.Text = "chkCar";
this.chkHouse.Name = "chkHouse";
this.chkHouse.Text = "chkHouse";
this.chkSea.Name = "chkSea";
this.chkSea.Text = "chkSea";
this.chkWood.Name = "chkWood";
this.chkWood.Text = "chkWood";
this.chkCar.CheckedChanged += new System.EventHandler(this.GeneralCheckboxItem_CheckedChanged);
this.chkHouse.CheckedChanged += new System.EventHandler(this.GeneralCheckboxItem_CheckedChanged);
this.chkSea.CheckedChanged += new System.EventHandler(this.GeneralCheckboxItem_CheckedChanged);
this.chkWood.CheckedChanged += new System.EventHandler(this.GeneralCheckboxItem_CheckedChanged);
}
private void GeneralCheckboxItem_CheckedChanged(object sender, EventArgs e)
{
MessageBox.Show(/*Name of changed checkbox*/);
}
}
}
感謝您的編輯,RedEyedMonster – pcnThird
沒錯!非常感謝 :) – MrMAG