Hi,

THe key to adding an event to the button is to use the AddHandler method to
reference the function handling the click.

This article does the job  
.http://www.devx.com/getHelpOn/10MinuteSolution/17430/1954?pf=true

...
         mybutton = New Button
            mybutton.Location = startPt
            mybutton.Text = i
            mybutton.ContextMenu = cmenu
            '---add the button to the form
            Me.Controls.Add(mybutton)
            '---add an event handler for the button
            AddHandler mybutton.Click, AddressOf button_Click

    Protected Sub button_Click(ByVal sender As _
      System.Object, ByVal e As System.EventArgs)
        '---event handler for the buttons
        MsgBox(CType(sender, Button).Text)
        '--do something for this item
        ...
        ...

    End Sub

GetSmartPaul
www.getsmartpaul.com


On Mon, 17 Jan 2005 07:03:32 +0900, Charles Carroll <[EMAIL PROTECTED]> wrote:
> 
> AddHandler
> 
> this control
> http://www.denisbauer.com/ASPNETControls/DynamicControlsPlaceholder.aspx
> really helps with Dynamic controls in general
> 
> 
> On Sun, 16 Jan 2005 14:30:33 -0700, Ali Husain <[EMAIL PROTECTED]> wrote:
> >  Does anyone know how to access the Click Event of a button that was
> >  created dynamically using
> >
> >  Dim newbutton as button
> >  Controls.add(newbutton)
> >
> >  Well the buttons create, but how do you set up the code for when you
> >  click on one of those buttons
> >
> >  Thanks,
> >
> >  Ali
> >
> >
> >
> >
> >  [Non-text portions of this message have been removed]
> >
> >
> >  ________________________________
> >  Yahoo! Groups Links
> >
> > To visit your group on the web, go to:
> > http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
> >
> > To unsubscribe from this group, send an email to:
> > [EMAIL PROTECTED]
> >   
> > Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
> 
> 
> Yahoo! Groups Links
> 
> 
> 
> 
>


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to