ListBox.SelectedIndexChanged

编程入门 行业动态 更新时间:2024-10-27 00:30:54
ListBox.SelectedIndexChanged - 你可以确定它是否是用户启动的?(ListBox.SelectedIndexChanged - can you determine if it was user initiated?)

我的问题类似于这样: 如何防止ListBox.SelectedIndexChanged事件? ,但我想问一个不同的方式。

有没有一种简单的方法来确定'SelectedIndexChanged'是否来自用户,而不是通过代码启动(例如ListBox.SelectedIndex = x)?

My question is similar to this: How to prevent ListBox.SelectedIndexChanged event?, but I want to ask it a different way.

Is there a simple way to determine if the 'SelectedIndexChanged' is coming from the user as opposed to initiated through code (e.g. ListBox.SelectedIndex = x)?

最满意答案

据我所知,不,没有简单的内置方法。 我已经能够做的最好的就是在代码改变之前设置一个标志,然后让事件处理程序重置标志并返回。

我想你可以开始检查调用堆栈,看看它是否在你自己的代码的某个地方发起,但我不确定这个工作值多少钱。

As far as I know, no, there's no simple way built-in. The best I've been able to do is set a flag just before changing it in code and then letting the event handler reset the flag and return.

I suppose you could start examining the call stack and see if it's originating somewhere in your own code or not, but I'm not sure how much it's worth the effort.

更多推荐

本文发布于:2023-07-09 14:57:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1087158.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:ListBox   SelectedIndexChanged

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!