|
-
Jul 26th, 2006, 01:12 PM
#1
Thread Starter
Hyperactive Member
[2005] Cut/paste controls on form
I noticed behavior has changed when cutting/pasting controls on forms that does not preserve/attach the code under the control to the pasted control.
For example, in a button's click event, I am referring to how the Handles Button1.Click part of the Sub declaration is removed from the original code and attached to a new sub-block. I understand the reason, but my question is:
When you want to cut and paste controls on the same form, how can you avoid this or what is the best practice for doing it? For example, I often do this when I decide I want to put my controls on a groupbox after I have alreaady coded events for them. I usually "cut" all the controls, lay down the groupbox and then "paste". But then I have to modify all this other code.
Here's an example of what I mean, in case it's not clear:
1) Drop a command button on a form.
2) Double click on it and add code to its click event that looks like:
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' some code
End Sub
3) Select command button on form and "cut".
4) Paste the button from the clipboard back onto the form.
5) Double-click on button and you get a new sub block with the old sub block modified:
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
' some code
End Sub
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End Sub
What I've been doing is copying the Button1_Click complete sub code, deleting all the Button1_Click subs, then clicking on the button again to create a new event-with Button1_Click as its name and pasting the code back in. Is there a better way?
Thanks for anything.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|