hello guys,
I want to display three buttons on the form when the program is run.
It's a very simple program, but there is nothing on the form when running. Could anybody help me out?
Thank you!
I want to display three buttons on the form when the program is run.
VB.NET:
[SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Public[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Class[/COLOR][/SIZE][SIZE=2] Form1
[/SIZE][SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] Form1_load()
[/SIZE][SIZE=2][COLOR=#0000ff]Call[/COLOR][/SIZE][SIZE=2] AddOKCancelButtons()
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000]' Create three buttons and place them on a form using
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000]' several size and location related properties.
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] AddOKCancelButtons()
[/SIZE][SIZE=2][COLOR=#008000]' Set the button size and location using
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000]' the Size and Location properties.
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] buttonOK [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Button()
buttonOK.Location = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Point(136, 248)
buttonOK.Size = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Size(75, 25)
[/SIZE][SIZE=2][COLOR=#008000]' Set the Text property and make the
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000]' button the form's default button.
[/COLOR][/SIZE][SIZE=2]buttonOK.Text = [/SIZE][SIZE=2][COLOR=#800000]"&OK"
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].AcceptButton = buttonOK
[/SIZE][SIZE=2][COLOR=#008000]' Set the button size and location using the Top,
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000]' Left, Width, and Height properties.
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] buttonCancel [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Button()
buttonCancel.Top = buttonOK.Top
buttonCancel.Left = buttonOK.Right + 5
buttonCancel.Width = buttonOK.Width
buttonCancel.Height = buttonOK.Height
[/SIZE][SIZE=2][COLOR=#008000]' Set the Text property and make the
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000]' button the form's cancel button.
[/COLOR][/SIZE][SIZE=2]buttonCancel.Text = [/SIZE][SIZE=2][COLOR=#800000]"&Cancel"
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].CancelButton = buttonCancel
[/SIZE][SIZE=2][COLOR=#008000]' Set the button size and location using
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000]' the Bounds property.
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] buttonHelp [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Button()
buttonHelp.Bounds = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Rectangle(10, 10, 75, 25)
[/SIZE][SIZE=2][COLOR=#008000]' Set the Text property of the button.
[/COLOR][/SIZE][SIZE=2]buttonHelp.Text = [/SIZE][SIZE=2][COLOR=#800000]"&Help"
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000]' Add the buttons to the form.
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].Controls.AddRange([/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Control() {buttonOK, buttonCancel, buttonHelp})
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub
End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Class
[/COLOR][/SIZE]
Thank you!