Dynamically Created Eventhandler and passing the textbox value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ahmadbaseet
    New Member
    • Aug 2007
    • 15

    #1

    Dynamically Created Eventhandler and passing the textbox value

    Hello all
    I am new to VB.NET. I am trying to create dynamically objects and giving them the event handles. Something like this
    [code=vbnet]
    Dim NewTab As New TabPage
    Dim NewTextBox As New TextBox
    Dim NewTab2 As New TabPage
    Dim b As New Button

    AddHandler b.Click, AddressOf b1

    Me.TabControl1. Controls.Add(Ne wTab)

    NewTab.Controls .Add(NewTextBox )
    NewTab.Controls .Add(b)

    Private Sub b1(ByVal sender As System.Object, ByVal e As System.EventArg s)
    MsgBox("Here I want the value of the textbox")
    End Sub
    [/code]
    I created a new tab and add two controls to it. One button and one textbox. Then i attached click event to the button. Now I want that onclick, I can see the text of the textbox of the tabpage. May be somebody can help me. Thanks in advance.
    Last edited by Frinavale; Mar 10 '08, 03:45 AM. Reason: Added [code] Tags
  • dwadish
    New Member
    • Nov 2006
    • 129

    #2
    Private Sub b1(ByVal sender As System.Object, ByVal e As System.EventArg s)Handles B1.Click
    MsgBox("Here I want the value of the textbox")
    End Sub

    Please specify one event handler her (click) or any related with this

    hope it will help you


    Originally posted by ahmadbaseet
    Hello all
    I am new to VB.NET. I am trying to create dynamically objects and giving them the event handles. Something like this

    Dim NewTab As New TabPage
    Dim NewTextBox As New TextBox
    Dim NewTab2 As New TabPage
    Dim b As New Button

    AddHandler b.Click, AddressOf b1

    Me.TabControl1. Controls.Add(Ne wTab)

    NewTab.Controls .Add(NewTextBox )
    NewTab.Controls .Add(b)

    Private Sub b1(ByVal sender As System.Object, ByVal e As System.EventArg s)
    MsgBox("Here I want the value of the textbox")
    End Sub

    I created a new tab and add two controls to it. One button and one textbox. Then i attached click event to the button. Now I want that onclick, I can see the text of the textbox of the tabpage. May be somebody can help me. Thanks in advance.

    Comment

    • ahmadbaseet
      New Member
      • Aug 2007
      • 15

      #3
      Hallo,

      May be you havent undestood my question. Actually i am making on pressing F4
      key a new tabpage, and on that page i have a button and a text box. I call a button:
      Dim b as new Button and box as Dim t as new Textbox

      Now I added a handler for click.

      Now How can I pass the text box value to a handler function? i.e. how can I see the text box value after clciking the button.

      Thanks

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        Originally posted by ahmadbaseet
        Hallo,

        May be you havent undestood my question. Actually i am making on pressing F4
        key a new tabpage, and on that page i have a button and a text box. I call a button:
        Dim b as new Button and box as Dim t as new Textbox

        Now I added a handler for click.

        Now How can I pass the text box value to a handler function? i.e. how can I see the text box value after clciking the button.

        Thanks
        Be sure to name your TextBox (give it a meaningful ID) and then use the FindControl method to locate it in the tab and retrieve it's text.

        -Frinny

        Comment

        Working...