1
C, C++, C#, Java, Visual Basic, HTML, PHP, CSS, Javascript, Ajax, Joomla, MySql y más / Programar Matrices de controles (Button) arrays o arreglos en Visual Basic
« en: 09 de Enero 2016, 23:27 »
He seguido los pasos del tutorial y he creado una matriz de controles (Button). En VB 6.0 era sencillo programar, por ejemplo, el evento Click, pero en VB2005 con lo que estoy ahora no veo la forma. En modo Diseño no deja crear la matriz de controles. ¿Cómo se puede hacer, para programar eventos?.
Añado el código.
Añado el código.
Código: [Seleccionar]
Public Class Prueba
Dim buttonarray(10) As Button
Dim i, j As Integer
Private Sub Prueba_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Width = 290
Me.Height = 500
For i = 1 To 10
buttonarray(i) = New Button
buttonarray(i).Font = New Font("Arial", 10, FontStyle.Bold)
buttonarray(i).Width = 40
buttonarray(i).Height = 25
buttonarray(i).Location = New Point(40, 19 + i * 36)
buttonarray(i).ForeColor = Color.Aquamarine
buttonarray(i).BackColor = Color.Blue
buttonarray(i).TextAlign = ContentAlignment.MiddleCenter
buttonarray(i).Text = i
Me.Controls.Add(buttonarray(i))
Next i
End Sub
[b]Private Sub buttonarray_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
j = buttonarray(TabIndex).Text
Label1.Text = "Has pulsado el Button......" & j
Resto del código
End Sub[/b]
Private Sub Finalizar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Finalizar.Click
End
End Sub
End Class