HI,

pleae can any one help me regarding the issue: I am trying to develop system where i can add run time some user control like button, textbox, checkbox .

Thanks
suman

hello
this code may help
in the click event of a button :

Dim tbox As New TextBox With {.Width = 200, .Name = "newtextbox", .Text = "hello", .Location = New Point(50, 100)}
        Me.Controls.Add(tbox)

this will create a 200px wide textbox in (50,100)px saying "hello"

HI,

pleae can any one help me regarding the issue: I am trying to develop system where i can add run time some user control like button, textbox, checkbox .

Thanks
suman

Adding controls without events, especially the ones mentioned, might be kind of pointless.
Since there is already a reply for creating a Dynamic textbox, I will add code for a Dynamic TextChanged event.

Here is an idea of how to get the proper procedure for each Dynamic event created, depending on the control.

Add a textbox to your form, double click it and you should see the following event.

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

    End Sub

Remove the "Handles TextBox1.TextChanged" and if needed, rename it.

Private Sub txt_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

Now you have an event to use, just no control to use it.:D

Here is complete code to create a Dynamic TextBox and give it an Event to use.
Code to create the textbox was located in the reply by "ÜnLoCo".

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '// design your textbox.
        Dim tbox As New TextBox With {.Width = 200, .Name = "newtextbox", .Text = "hello", .Location = New Point(50, 100)}
        '// add the textbox to your Form.
        Me.Controls.Add(tbox)
        '// add an event handler for the textbox, and give it the address of the event to use.
        AddHandler tbox.TextChanged, AddressOf txt_TextChanged
        '// for testing purposes only.
        Me.Text = "0"
    End Sub

    Private Sub txt_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.Text += 1
    End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.