Jump to content

Q: adding buttons during runtime?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
encio

encio

    Newbie

  • Members
  • PipPip
  • 23 posts
im just wondering if visual basic has the ability to add buttons(command button,option,checkbox and the likes) during runtime?

for example , you want to have a list of supplier to be handled by the radio button.. but then during the coding process you dont know yet how many supplier there would be, so you want to write a program that would automatically add radio button everytime a new supplier added..

if it's possible, how? or do you have some techniques do such?

#2
Vswe

Vswe

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 9,552 posts
Dim myButton As New Button
myButton.Parent = Me
myButton.Size = New Size(40,20)
myButton.Location = New Point(10,10)


#3
encio

encio

    Newbie

  • Members
  • PipPip
  • 23 posts
ok, how do you call it?

Dim myButton As New Button
dim x,y as integer

x = adodc1.recordset.recordcount
for y = 1 to x
myButton.Parent = Me
myButton.Size = New Size(40,20)
myButton.Location = New Point(10,10)
next y

what it does is it will place the button of the top of each other right?

#4
Vswe

Vswe

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 9,552 posts
in your example it will only create one button since your creation is outside the loop:

Dim myButton As New Button

The size and locations were of course just examples, if you want them to be different in a loop you can just use the loop variable to change the location accordingly:

myButton.Location = New Point(10,30*y)
for example...

#5
encio

encio

    Newbie

  • Members
  • PipPip
  • 23 posts
oohh.. okay, i get the point.. thanks for your help, i'm just starting with visual basic so i had to ask those nooby question.
again thank you!