Welcome to Dream.In.Code
Become a VB Expert!

Join 137,231 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,847 people online right now. Registration is fast and FREE... Join Now!




buttons add into form load

 
Reply to this topicStart new topic

buttons add into form load, vb 2003

nb718
21 Feb, 2007 - 08:11 AM
Post #1

New D.I.C Head
*

Joined: 21 Feb, 2007
Posts: 4


My Contributions
I would like to add buttons on a form during the form load, and I have following code, but its is nothing happen....

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Dim btn() As Button
Dim x, y, x1, y1 As Integer
x = 0
y = 0
x1 = 100
y1 = 100

For i = 0 To 4
btn(i) = New Button
btn(i).Visible = True
btn(i).Location = New Point(x, y)
btn(i).Size = New Size(x1, y1)
btn(i).Top = 50
btn(i).Width = 100
btn(i).Height = 100
btn(i).Left = 50
ActiveForm.Controls.Add(btn(i))
x += x1
y += y1

Next


Catch ex As Exception

End Try

End sub

End class



Attached File(s)
Attached File  imgLoadTest.zip ( 229.8k ) Number of downloads: 35
User is offlineProfile CardPM
+Quote Post

m2s87
RE: Buttons Add Into Form Load
21 Feb, 2007 - 08:57 AM
Post #2

D.I.C Regular
Group Icon

Joined: 28 Nov, 2006
Posts: 390



Thanked: 1 times
Dream Kudos: 1225
My Contributions
Would the following snippet be any help? Snippet
Because i think it does ~just that.
User is offlineProfile CardPM
+Quote Post

nb718
RE: Buttons Add Into Form Load
22 Feb, 2007 - 11:25 AM
Post #3

New D.I.C Head
*

Joined: 21 Feb, 2007
Posts: 4


My Contributions
QUOTE(m2s87 @ 21 Feb, 2007 - 09:57 AM) *

Would the following snippet be any help? Snippet
Because i think it does ~just that.


how to fill buttons each other on the panel1 depends on panel1's size i/o those const integers?

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/4/08 03:25PM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month