开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜