Paul thanks for the info. works like a charm.. Except that how can I
specify which button is being clicked
 
Is there a way I can get the index number of that button.
 
Thanks
 
Ali
 
 
 
.           Dim menuButton As New Button
.
        Controls.Add(menuButton)
                    AddHandler menuButton.Click, AddressOf
menuButton_click
 
.
   Protected Sub menuButton_click(ByVal sender As System.Object, ByVal e
As System.EventArgs)
        MsgBox("Test ")
    End Sub
 
-----Original Message-----
From: Paul N. Chu [mailto:[EMAIL PROTECTED] 
Sent: Sunday, January 16, 2005 11:22 PM
To: [email protected]
Subject: Re: [AspNetAnyQuestionIsOk] Vb.Net Question
 
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]
<mailto:[EMAIL PROTECTED]
cribe> 
  
*         Your use of Yahoo! Groups is subject to the Yahoo! Terms of
<http://docs.yahoo.com/info/terms/>  Service. 


[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:
    http://docs.yahoo.com/info/terms/
 



Reply via email to