Foros del Web » Programación para mayores de 30 ;) » .NET »

Texto en Botones Visual Basic 2010

Estas en el tema de Texto en Botones Visual Basic 2010 en el foro de .NET en Foros del Web. Buenos Dias amigo vengo a pedirles algo de ayuda para colocarle un texto y valor a unos botones que son creados dinamicamentes con una base ...
  #1 (permalink)  
Antiguo 27/03/2012, 08:53
 
Fecha de Ingreso: noviembre-2009
Mensajes: 89
Antigüedad: 14 años, 4 meses
Puntos: 1
Exclamación Texto en Botones Visual Basic 2010

Buenos Dias amigo vengo a pedirles algo de ayuda para colocarle un texto y valor a unos botones que son creados dinamicamentes con una base de dato mysql..

El codigo que tengo es el siguiente:

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

Este codigo me genera lo siguiente: http://imageshack.us/photo/my-images/571/pantallax.jpg/
  #2 (permalink)  
Antiguo 27/03/2012, 09:03
Avatar de Aquaventus  
Fecha de Ingreso: junio-2010
Ubicación: Lima-Peru , En el alba de la naturaleza
Mensajes: 2.105
Antigüedad: 13 años, 9 meses
Puntos: 267
Respuesta: Texto en Botones Visual Basic 2010

snowdogs si vas a preguntar algo en un hilo ya no crees otro, ya que causas desorden al momento de responder.
POST RESPONDIDO -> botones dinamicos.
__________________
Internet es tener todo el conocimiento global a tu disposición.
Desarrollo de Software - Ejemplos .Net

Etiquetas: basic, botones, sql, tabla, visual
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 16:54.