ListBox.SelectedIndexChanged - 你可以确定是否被用户注册? [英] ListBox.SelectedIndexChanged - can you determine if it was user intiated?

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

问题描述

我的问题类似于此:如何阻止ListBox.SelectedIndexChanged事件? a>,但是我想要一个不同的方式。

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天全站免登陆