ListBox.SelectedIndexChanged-您可以确定它是否由用户启动吗? [英] ListBox.SelectedIndexChanged - can you determine if it was user initiated?

查看:75
本文介绍了ListBox.SelectedIndexChanged-您可以确定它是否由用户启动吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题与此类似:如何防止ListBox.SelectedIndexChanged事件?,但是我想问一个不同的方法.

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

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

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.

这篇关于ListBox.SelectedIndexChanged-您可以确定它是否由用户启动吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆