properties of control changed

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • raamay
    New Member
    • Feb 2007
    • 107

    properties of control changed

    i had designed a form with various controls added some days ago. Accordingly i had coded the controls. And today i didnt like the look and feel of the form, so i copied the controls for a while and then re-pasted it over a new control (panel). Now when i double click to see the underlying code of the control generates a new event. I mean i had a button as Button1 and its underlying code was under the Button1_Click event. But now its is like Button1_Click_1 which i dont understand. Is it due to formation of control array or what? I want the button to be remapped to Button1_Click event.

    Please direct me. It is in Visual Basic 2008 Express Edition
  • aryanbs
    New Member
    • Mar 2009
    • 42

    #2
    Thats the common thing, what you do is delete the new one Button1_Click_1 ...
    and in the old one at the end just put .........handles button1.click

    In the future, instead of copy and paste that way, use Document Outline, which is in View Menu, Other Windows

    That helps you to drag and drop control from one container to other without losing event handler

    Comment

    • raamay
      New Member
      • Feb 2007
      • 107

      #3
      thankyou for the information. I will keep it in mind so i dont create the blunder onceagain.

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        It's happening because when you create a button on the form, the code that declares/defines/instantiates the button is automatically generated for you by Visual Studio and is added to the .design.vb file (which you may not see if you aren't viewing hidden files in the solution explorer). The button is declared in the .design.vb file so that you can access it in both the Designer view and in the VB code view using Visual Studio.

        If you cut the button, the declaration may not be removed from the .design.vb file. Therefore, when you past the button it will name the pasted button differently than what you had originally named it so that there is no conflict with the button already declared in the .design.vb file.

        As already suggested, the best way to get around this is to copy the button, then Delete the button, then paste the button. This method is more likely to remove the button declaration from the .design.vb file than cutting the button.

        If you know that the button no longer exists, then you can edit the .design.vb file and remove the button declaration. This will let you name the button to what you want...otherwis e Visual Studio will give you a message stating that a button already exists with the name that you are trying to give it.

        -Frinny

        Comment

        • raamay
          New Member
          • Feb 2007
          • 107

          #5
          thankyou and i am obliged for the fruitful information.

          Comment

          Working...