简体   繁体   English

双击按钮不会打开其代码隐藏

[英]Double-clicking a button doesn't open its code-behind

I'm making a windows form using c# and added 3 buttons. 我正在使用c#创建一个Windows窗体并添加了3个按钮。 When I double click on any object, it takes me to the code, the specific function that gets called when that object is activated, depending on its type. 当我双击任何对象时,它会转到代码,即激活该对象时调用的特定函数,具体取决于其类型。 However, when I double click on the 2nd or 3rd buttons, it takes me to button 1's code instead of opening the function called by double clicking on the button I pressed. 但是,当我双击第二个或第三个按钮时,我需要按下1的代码而不是通过双击我按下的按钮打开调用的函数。

Help? 救命?

That happens when all 3 buttons are assigned to the same event. 当所有3个按钮分配给同一事件时,会发生这种情况。 Select the 2 wrong buttons and delete their event in the properties window. 选择2个错误按钮并在属性窗口中删除它们的事件。 Now doubleclicking one of them will create a new code template for it.. You probably had the three all selected when you created the 1st event.. 现在双击其中一个将为它创建一个新的代码模板..当你创建第一个事件时,你可能已经选择了三个。

通过每个按钮的属性窗口删除按钮单击事件,并将它们重新分配。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM