【发布时间】:2010-04-01 00:26:44
【问题描述】:
由于某些非常奇怪的原因,当我在小型 GUI 上的简单文本框上将 .Enabled 属性设置为 false 时,它会触发单选按钮 OnClick 事件并导致很多问题。
我已经为 txtBox.Enabled = false; 设置了断点。并且在跨过或进入它之后,我直接跳转到单选按钮控件的 OnClick 事件
这是发生的调用堆栈:
TestGUI.exe!TestGUI.frmMain.radiobuttonClicked(object sender = {Text = "Download Single Episode" Checked = true}, System.EventArgs e = {System.EventArgs}) 第 67 行 C# System.Windows.Forms.dll!System.Windows.Forms.Control.OnClick(System.EventArgs e) + 0x70 字节 System.Windows.Forms.dll!System.Windows.Forms.RadioButton.OnClick(System.EventArgs e) + 0x27 字节 System.Windows.Forms.dll!System.Windows.Forms.RadioButton.OnEnter(System.EventArgs e = {System.EventArgs}) + 0x3e 字节 System.Windows.Forms.dll!System.Windows.Forms.Control.NotifyEnter() + 0x20 字节 System.Windows.Forms.dll!System.Windows.Forms.ContainerControl.UpdateFocusedControl() + 0x195 字节 System.Windows.Forms.dll!System.Windows.Forms.ContainerControl.AssignActiveControlInternal(System.Windows.Forms.Control value = {Text = "Download Single Episode" Checked = true}) + 0x54 字节 System.Windows.Forms.dll!System.Windows.Forms.ContainerControl.ActivateControlInternal(System.Windows.Forms.Control control, bool originator = false) + 0x76 bytes System.Windows.Forms.dll!System.Windows.Forms.ContainerControl.SetActiveControlInternal(System.Windows.Forms.Control value = {Text = "Download Single Episode" Checked = true}) + 0x73 字节 System.Windows.Forms.dll!System.Windows.Forms.ContainerControl.SetActiveControl(System.Windows.Forms.Control ctl) + 0x33 字节 System.Windows.Forms.dll!System.Windows.Forms.ContainerControl.ActiveControl.set(System.Windows.Forms.Control 值) + 0x5 字节 System.Windows.Forms.dll!System.Windows.Forms.Control.Select(布尔定向,布尔转发)+ 0x1b 字节 System.Windows.Forms.dll!System.Windows.Forms.Control.SelectNextControl(System.Windows.Forms.Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap) + 0x7b 字节 System.Windows.Forms.dll!System.Windows.Forms.Control.SelectNextControlInternal(System.Windows.Forms.Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap) + 0x4a 字节 System.Windows.Forms.dll!System.Windows.Forms.Control.SelectNextIfFocused() + 0x61 字节 System.Windows.Forms.dll!System.Windows.Forms.Control.Enabled.set(bool value) + 0x42 bytes
什么鬼?
这和我订阅事件的方式没有任何关系吧?
this.radioBtnMultipleDownload.Click += radiobuttonClicked;
this.radioBtnSingleDownload.Click += radiobuttonClicked;
this.radioCustomUrl.Click += radiobuttonClicked;
【问题讨论】:
-
我遇到了完全相同的问题。一篇文章是:social.msdn.microsoft.com/Forums/windows/en-US/…
标签: c# user-interface controls events