buttons stopped working

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dave Cullen

    #1

    buttons stopped working

    I did a cut & paste of some button controls on one of my forms and now
    the button procedures don't get called when the buttons are pushed.
    Somehow dotnet has disassociated the buttons with their previous code.

    If I double-click the buttons in design mode, dotnet wants to create new
    click procedures for them with names appended with _1 (example: Private
    Sub ButtonQuit_Clic k_1)

    The question is, how do I make the button procedures match the control
    names again?

    The properties sheets on the controls still show them by their original
    names. If it matters, I pasted the controls onto the form after adding a
    tab control.

    Dotnet version is 2002 SP1

    Thanks
  • Phill W.

    #2
    Re: buttons stopped working

    Dave Cullen wrote:
    I did a cut & paste of some button controls on one of my forms and now
    the button procedures don't get called when the buttons are pushed.
    The "Handles" clauses get /dropped/ when you cut and paste controls
    around. It's just something the IDE does.

    You'll have to find each event handler in the code and add the Handles
    clauses again.

    Next time you feel the urge to move controls around like htis, add the
    Tab Control and Tab Page to the form, save it, close the Designer and
    open up the code Region that's marked "Do Not Change" .. and change it.

    Look for the lines of code that add each Control to the Form:

    Me.Controls.Add ( Me.X )

    If Me.X is one of the Controls that you want to move onto the Tab Page
    (called, say, Me.Tab1), change the above line to

    Me.Tab1.Control s.Add( X )

    Save the Form, rebuild the project, cross your fingers and open the
    Designer. With a /bit/ of luck, your controls will have moved onto the
    tab page and will still have all their event handlers attached.

    HTH,
    Phill W.

    Comment

    • Robinson

      #3
      Re: buttons stopped working


      "Dave Cullen" <nospam@mail.co mwrote in message
      news:450FFE11.7 CCE1680@mail.co m...
      >I did a cut & paste of some button controls on one of my forms and now
      the button procedures don't get called when the buttons are pushed.
      Somehow dotnet has disassociated the buttons with their previous code.
      >
      If I double-click the buttons in design mode, dotnet wants to create new
      click procedures for them with names appended with _1 (example: Private
      Sub ButtonQuit_Clic k_1)
      >
      The question is, how do I make the button procedures match the control
      names again?
      >
      The properties sheets on the controls still show them by their original
      names. If it matters, I pasted the controls onto the form after adding a
      tab control.
      >
      Dotnet version is 2002 SP1
      >
      If you look at the "Handles" keyword after the event handler declaration,
      you will see that it is no longer associated with the control. Simply
      re-insert the "Handles myControl.abc" to make it work again.

      i.e.:

      Private Sub DataTreeView_Lo ad(ByVal sender As Object, ByVal e As
      System.EventArg s) Handles MyBase.Load

      becomes........ .

      Private Sub DataTreeView_Lo ad(ByVal sender As Object, ByVal e As
      System.EventArg s)

      so, add the "Handles MyBase.Load" in this example.



      Comment

      • Dave Cullen

        #4
        Re: buttons stopped working

        You guys rock. Thanks very much.


        Robinson wrote:
        >
        "Dave Cullen" <nospam@mail.co mwrote in message
        news:450FFE11.7 CCE1680@mail.co m...
        I did a cut & paste of some button controls on one of my forms and now
        the button procedures don't get called when the buttons are pushed.
        Somehow dotnet has disassociated the buttons with their previous code.

        If I double-click the buttons in design mode, dotnet wants to create new
        click procedures for them with names appended with _1 (example: Private
        Sub ButtonQuit_Clic k_1)

        The question is, how do I make the button procedures match the control
        names again?

        The properties sheets on the controls still show them by their original
        names. If it matters, I pasted the controls onto the form after adding a
        tab control.

        Dotnet version is 2002 SP1
        >
        If you look at the "Handles" keyword after the event handler declaration,
        you will see that it is no longer associated with the control. Simply
        re-insert the "Handles myControl.abc" to make it work again.
        >
        i.e.:
        >
        Private Sub DataTreeView_Lo ad(ByVal sender As Object, ByVal e As
        System.EventArg s) Handles MyBase.Load
        >
        becomes........ .
        >
        Private Sub DataTreeView_Lo ad(ByVal sender As Object, ByVal e As
        System.EventArg s)
        >
        so, add the "Handles MyBase.Load" in this example.

        Comment

        Working...