R
Ron
Can anyone help me out? I am trying to add buttons numbered one
through 10 at runtime to a form.
I think they are getting added but they seem to be getting stacked one
on top of each other. so I only see 1, and not the others.
here is what I am doing can anyone tell me what I am doing wrong?
Public Class Form1
Public buttons(9) As Button
Const buttonwh As Integer = 30
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim i, j, row As Integer
Dim pntcurrent As Point
For i = 0 To 9
j = i + 1
pntcurrent = New Point(j + (buttonwh + 8), row)
Call createbuttons(i, pntcurrent)
Next
For k As Integer = 0 To buttons.GetUpperBound(0)
AddHandler buttons(k).Click, AddressOf Button_click
Next
End Sub
Private Sub createbuttons(ByVal i As Integer, _
ByVal pnt As Point)
buttons(i) = New Button
buttons(i).Enabled = True
buttons(i).Visible = True
buttons(i).Text = Convert.ToString(i + 1)
buttons(i).Size = New _
System.Drawing.Size(buttonwh, buttonwh)
buttons(i).Location = pnt
Me.Controls.Add(buttons(i))
End Sub
Private Sub button_click(ByVal sender As System.Object, _
ByVal e As System.EventArgs)
End Sub
End Class
through 10 at runtime to a form.
I think they are getting added but they seem to be getting stacked one
on top of each other. so I only see 1, and not the others.
here is what I am doing can anyone tell me what I am doing wrong?
Public Class Form1
Public buttons(9) As Button
Const buttonwh As Integer = 30
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim i, j, row As Integer
Dim pntcurrent As Point
For i = 0 To 9
j = i + 1
pntcurrent = New Point(j + (buttonwh + 8), row)
Call createbuttons(i, pntcurrent)
Next
For k As Integer = 0 To buttons.GetUpperBound(0)
AddHandler buttons(k).Click, AddressOf Button_click
Next
End Sub
Private Sub createbuttons(ByVal i As Integer, _
ByVal pnt As Point)
buttons(i) = New Button
buttons(i).Enabled = True
buttons(i).Visible = True
buttons(i).Text = Convert.ToString(i + 1)
buttons(i).Size = New _
System.Drawing.Size(buttonwh, buttonwh)
buttons(i).Location = pnt
Me.Controls.Add(buttons(i))
End Sub
Private Sub button_click(ByVal sender As System.Object, _
ByVal e As System.EventArgs)
End Sub
End Class