主要程式碼:
int i = 0;
bool b = false;
private void pictureBox1_Click(object sender, EventArgs e)
{
i = i ^ 1; //做 xor 運算 ,按一下 True ,再按一下 False.........
b = Convert.ToBoolean(i);
if (b)
{
pictureBox1.Image = Properties.Resources.switch_on;
}
else
{
pictureBox1.Image = Properties.Resources.switch_off;
}
}
示例:
範例檔:
https://mega.nz/#!fCJjHa7R!BBXSQOXM7fUFSYCTJA7KJVO8WAM0MKEZaEldF5ZMi1Y
One comment
哈哈哈,写的太好了https://www.cscnn.com/