I had a working program (Windows Forms Project) complete with buttons, labels, textboxes e.t.c. and the underlying code.
我有一个工作程序(Windows窗体项目),包括按钮,标签,文本框e.t.c.和底层代码。
In an attempt to shortcut my work, I decided to add tab controls and move everything in my main form into tab 1 (cut and pasted). As you can imagine it didn't work. I then got rid of the tab conrol and pasted everything back into the main form but the program doesn't work anymore. Can someone tell me what's wrong please?
为了简化我的工作,我决定添加选项卡控件并将主窗体中的所有内容移动到选项卡1(剪切和粘贴)。你可以想象它没有用。然后,我删除了选项卡控件并将所有内容粘贴回主窗体,但程序不再起作用。有人可以告诉我有什么问题吗?
I'm working in MS V studio 2008 express Thanks.
我在MS V studio 2008表达谢谢。
3 个解决方案
#1
1
The event handlers that you coded are still there. However, they are not associated with the control any more. I'm not sure if you're using VB.Net or C#, but the fix is the same - it's manual and tedious if you have a bunch of controls, but not too difficult. Here are the instructions for fixing a single button control, and you'll have to apply the concepts across the board.
您编码的事件处理程序仍然存在。但是,它们不再与控件相关联。我不确定你是使用VB.Net还是C#,但修复方法是一样的 - 如果你有一堆控件,这是手动和乏味的,但并不太难。以下是修复单个按钮控件的说明,您必须全面应用这些概念。
These instructions are specific to C#. I can give you VB instructions as well as I've done this plenty of times.
这些说明特定于C#。我可以给你VB指令以及我已经做了很多次。
Double click on the button to generate a new event handler. If the button is named Button1, the original event handler was probably called Button1_Click. Now it should be Button1_Click1.
双击该按钮以生成新的事件处理程序。如果按钮名为Button1,则原始事件处理程序可能称为Button1_Click。现在它应该是Button1_Click1。
Delete the Button1_Click1 function and compile. You'll get errors and if you doible-click on the error in the error pane it will take you to the form,designer.cs file to a line that looks like:
删除Button1_Click1函数并编译。您将收到错误,如果您在错误窗格中单击错误,则会将表单designer.cs文件转到以下行:
this.Button1.Click += new System.EventHandler(this.Button1_Click1);
Change this to
将此更改为
this.Button1.Click += new System.EventHandler(this.Button1_Click);
to point to the previously existing event handler, and the event handler will be fixed.
指向先前存在的事件处理程序,并修复事件处理程序。
#2
4
I have done this many times, but I usually just drag them into the TabControl. Maybe in the cut and paste operation your controls have become unwired from the event declarations.
我已经做了很多次,但我通常只是将它们拖到TabControl中。也许在剪切和粘贴操作中,您的控件已从事件声明中取消连接。
#3
0
Possibly some of the events had code lost. If you do it again it will probably work. For an alternative method see my message
可能有些事件丢失了代码。如果你再做一次它可能会有效。有关替代方法,请参阅我的消息
#1
1
The event handlers that you coded are still there. However, they are not associated with the control any more. I'm not sure if you're using VB.Net or C#, but the fix is the same - it's manual and tedious if you have a bunch of controls, but not too difficult. Here are the instructions for fixing a single button control, and you'll have to apply the concepts across the board.
您编码的事件处理程序仍然存在。但是,它们不再与控件相关联。我不确定你是使用VB.Net还是C#,但修复方法是一样的 - 如果你有一堆控件,这是手动和乏味的,但并不太难。以下是修复单个按钮控件的说明,您必须全面应用这些概念。
These instructions are specific to C#. I can give you VB instructions as well as I've done this plenty of times.
这些说明特定于C#。我可以给你VB指令以及我已经做了很多次。
Double click on the button to generate a new event handler. If the button is named Button1, the original event handler was probably called Button1_Click. Now it should be Button1_Click1.
双击该按钮以生成新的事件处理程序。如果按钮名为Button1,则原始事件处理程序可能称为Button1_Click。现在它应该是Button1_Click1。
Delete the Button1_Click1 function and compile. You'll get errors and if you doible-click on the error in the error pane it will take you to the form,designer.cs file to a line that looks like:
删除Button1_Click1函数并编译。您将收到错误,如果您在错误窗格中单击错误,则会将表单designer.cs文件转到以下行:
this.Button1.Click += new System.EventHandler(this.Button1_Click1);
Change this to
将此更改为
this.Button1.Click += new System.EventHandler(this.Button1_Click);
to point to the previously existing event handler, and the event handler will be fixed.
指向先前存在的事件处理程序,并修复事件处理程序。
#2
4
I have done this many times, but I usually just drag them into the TabControl. Maybe in the cut and paste operation your controls have become unwired from the event declarations.
我已经做了很多次,但我通常只是将它们拖到TabControl中。也许在剪切和粘贴操作中,您的控件已从事件声明中取消连接。
#3
0
Possibly some of the events had code lost. If you do it again it will probably work. For an alternative method see my message
可能有些事件丢失了代码。如果你再做一次它可能会有效。有关替代方法,请参阅我的消息