Adding button to form programatically

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

You peops are probably going to get sick of me over the next few weeks :)

I am trying to add a button via code when an existing button is clicked.

I have the following bits of code (missed out unimportant stuff)

At module level:

Dim WithEvents Button2 as Button

At button1 click event:

Button2 = New Button
Button2.location = New Point(104,104)
Button2.size = New Size(75,23)
Button.Text = "New Button"
Textbox1.Text = "Created new button"

When Button1 is clicked

TextBoxt1.Text property is updated but Button2 does not appear

I have msgbox'd button2.location.x and it returns 104!

What am I doing wrong

Regards
 
Back
Top