Ver Mensaje Individual
  #12 (permalink)  
Antiguo 16/03/2012, 08:45
snowdogs
 
Fecha de Ingreso: noviembre-2009
Mensajes: 89
Antigüedad: 14 años, 5 meses
Puntos: 1
Respuesta: Botones Dinamicos

Hola Aquaventus como estas? porfin logre hacer los botones ahora tengo otro problemita que creo es mas facil.. lo que quiero hacer es:

Si se me crean por ejemplo 8 botones, quiero hacer que por lo menos si presiono el boton 1 al presionar el boton 2 me salga un msj diciendo que esa combinacion no esta permitida y no haga nada.. hay varias combinaciones que no son permitidas..

El codigo que tengo para crear los botones es este:

Código vb:
Ver original
  1. Public Class Form1
  2.     Dim logros(10) As Label
  3.     Dim codDeporte As Integer = 1 'Beisbol
  4.    Dim Partidos() As GroupBox
  5.     Dim totalPartidos As Integer = 0
  6.     Dim totalLogros As Integer = 0
  7.     Dim BotonEquipo1(,) As Button
  8.     Dim BotonEquipo2(,) As Button
  9.     Sub CrearPartido(ByVal nombreEquipo1 As String, ByVal nombreEquipo2 As String)
  10.         ReDim Preserve Partidos(totalPartidos)
  11.         Dim x As Integer = 100
  12.         Dim i As Integer
  13.         Dim separacion As Integer = 75
  14.         Dim equipo1 As New Label
  15.         Dim equipo2 As New Label
  16.         equipo1.Text = nombreEquipo1
  17.         equipo2.Text = nombreEquipo2
  18.         equipo1.AutoSize = True
  19.         equipo2.AutoSize = True
  20.         equipo1.Location = New Point(15, 20)
  21.         equipo2.Location = New Point(15, 55)
  22.         Partidos(totalPartidos) = New GroupBox
  23.         Partidos(totalPartidos).Size = New Size(800, 90)
  24.         'Partidos(totalPartidos).BackColor = Color.Gray
  25.        Partidos(totalPartidos).Location = New Point(4, 90 * (totalPartidos + 1))
  26.         Partidos(totalPartidos).Controls.Add(equipo1)
  27.         Partidos(totalPartidos).Controls.Add(equipo2)
  28.         For i = 1 To totalLogros
  29.             ReDim BotonEquipo1(totalPartidos, i)
  30.             BotonEquipo1(totalPartidos, i) = New Button
  31.             BotonEquipo1(totalPartidos, i).Size = New Size(33, 20)
  32.             BotonEquipo1(totalPartidos, i).Location = New Point(x, 20)
  33.             Partidos(totalPartidos).Controls.Add(BotonEquipo1(totalPartidos, i))
  34.  
  35.             ReDim BotonEquipo2(totalPartidos, i)
  36.             BotonEquipo2(totalPartidos, i) = New Button
  37.             BotonEquipo2(totalPartidos, i).Size = New Size(33, 20)
  38.             BotonEquipo2(totalPartidos, i).Location = New Point(x, 55)
  39.             Partidos(totalPartidos).Controls.Add(BotonEquipo2(totalPartidos, i))
  40.  
  41.             x = x + separacion
  42.  
  43.         Next
  44.  
  45.         Me.Controls.Add(Partidos(totalPartidos))
  46.         totalPartidos = totalPartidos + 1
  47.     End Sub
  48.     Sub CrearFormulario()
  49.         Dim tabla As OdbcDataReader
  50.         Dim conex As New Conexion
  51.         Dim contador As Integer = 0
  52.         Dim x As Integer = 100
  53.         Dim separacion As Integer = 75
  54.         tabla = conex.consultar("select *from tipoapuesta where codDeporte = " & codDeporte)
  55.         While tabla.Read
  56.             logros(contador) = New Label
  57.             logros(contador).Text = tabla.GetValue(2)
  58.             logros(contador).Location = New Point(x, 40)
  59.             logros(contador).AutoSize = True
  60.             Me.Controls.Add(logros(contador))
  61.             contador = contador + 1
  62.             x = x + separacion
  63.         End While
  64.         totalLogros = contador
  65.     End Sub
  66.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  67.         CrearFormulario()
  68.         mostrarJuegos()
  69.     End Sub
  70.     Sub mostrarJuegos()
  71.         Dim fecha As String
  72.         Dim sql As String
  73.         Dim Conex As New Conexion
  74.         Dim Tabla As OdbcDataReader
  75.         fecha = Format(Now, "yyyy-MM-dd")
  76.         sql = "SELECT codPartido,fecha,horaInicio, a.nombre,b.nombre FROM partidos p, equipos a, equipos b WHERE p.nombreEA = a.codEquipo AND p.nombreEB = b.codEquipo AND fecha='" & fecha & "'"
  77.         Tabla = Conex.consultar(sql)
  78.         While Tabla.Read
  79.             CrearPartido(Tabla(3), Tabla(4))
  80.         End While
  81.  
  82.  
  83.     End Sub
  84.  
  85. End Class

Espero me puedas ayudar con algo de codigo amigo, que estes bien y disculpa tanta molestia.