开发者

Differentiate between the program setting a checkbox and the user clicking it

开发者 https://www.devze.com 2023-04-09 21:53 出处:网络
I want to know if there is a way to differentiate between the user click开发者_运维问答ing a checkbox, in which case I would like the following event to trigger, and the program itself setting the che

I want to know if there is a way to differentiate between the user click开发者_运维问答ing a checkbox, in which case I would like the following event to trigger, and the program itself setting the checked state, in which case I would like it to do nothing.

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
    {
        if (sList.SelectedIndex != -1)
        {
            if (checkBox1.Checked)
                CList[sList.SelectedIndex]._object[1] += 8;
            else
                CList[sList.SelectedIndex]._object[1] -= 8;
        }
    }

I just can't seem to find much about this issue. Thanks for your time.


You could also handle the click event of the checkbox. I don't know if that event is fired before or after checkedchanged, but if it happens before you could set a boolean to true or something and read it in checkedchanged.

0

精彩评论

暂无评论...
验证码 换一张
取 消