0

Hey guys,

I want to write code that does something like this:

If option = 1 Then
Create one Button and display it
Else If option = 2 Then
Create two Buttons and display them
End If


To do this, can I simply do:

If option = 1 Then
     Dim Button1 as Button
     Me.Button1.Show()
End If

And on like that?

Thanks,
JP

4
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by aquamarine_kath
0

Unless you're willing to use Windows API calls, VB doesn't really do dynamic control creation very well. Partly this is because of the whole event procedure registration thing, callback function stuff and the like.

As a workaround, you can create the necessary buttons at design time, but make them Visible = False. Then, when you evaluate your Option variable as above (whatever it is) you can selectively unhide the buttons you've created.

Hope this helps!

0

I don't understand what you want? You want to create a button or show a button? so more details.................

0

Just like what BitBit said, try to create a button during design time and make it visible = false in the property window.

When u need it, u can unhide it or make it visible like this:

Command1.visible = true
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.