Portal    Foro    Buscar    FAQ    Registrarse    Conectarse

Como Detectar Evento En Formulario Creado Por Código?

Como Detectar Evento En Formulario Creado Por Código?
Artículo
Responder citando    Descargar mensaje  
Mensaje Como Detectar Evento En Formulario Creado Por Código? 
 

Public Sub MensajeFinalJuego()
 Dim ventana As Form
 Dim boton1 As Button, boton2 As Button
 
 ventana = New Form
 boton1 = New Button(ventana)
 boton2 = New Button(ventana)
 
 With ventana
  .Center
  .Caption = "Advertencia"
  .Width = 600
  .Height = 300
  .Border = False
 End With
 
 With boton1
  .Text = "Estoy seguro, anota"
  .x = 30
  .y = 150
  .Width = 200
  .Height = 50
 End With
 
 With boton2
  .Text = "No anotar"
  .x = 300
  .y = 150
  .Width = 150
  .Height = 50
 End With
 ventana.Show
 
End
 



supongamos que llamo a esa subrutina que crea un formulario y dos botones, mi pregunta es como detecto el evento click en los botones???????  



 
v3ctor - Ver perfil del usuario Enviar mensaje privado  
v3ctor [ Viernes, 27 Junio 2014, 14:45 ]
 


Como Detectar Evento En Formulario Creado Por Código?
Comentarios
Responder citando    Descargar mensaje  
Mensaje Re: Como Detectar Evento En Formulario Creado Por Código? 
 
Ante todo tienes que atribuir ellos a un grupo de eventos.
Por ejemplo:
....
 boton1 = New Button(ventana) As "NombreDelGrupo"
 boton2 = New Button(ventana) As "NombreDelGrupo"
....
....
End

Public Sub NombreDelGrupo_Click()
  
' Identificamos el Button presionado por una su propiedad... por ejemplo el su texto:
Select Case Last.Text
  Case "Estoy seguro, anota"
    Print "Apretado el button1"
  Case "No anotar"
    Print "Apretado el button2"
End Select
 
End


Es claro que tu puedes atribuir cada boton a un propio unico grupo.



 
última edición por vuott el Viernes, 27 Junio 2014, 16:17; editado 3 veces 
vuott - Ver perfil del usuario Enviar mensaje privado  
vuott [ Viernes, 27 Junio 2014, 15:56 ]
Responder citando    Descargar mensaje  
Mensaje Re: Como Detectar Evento En Formulario Creado Por Código? 
 
gracias vuott

' gambas module file


Public Sub MensajeFinalJuego()
 Dim ventana As Form
 Dim boton1 As Button, boton2 As Button
 
 ventana = New Form
 boton1 = New Button(ventana) As "boton1"
 boton2 = New Button(ventana) As "boton2"
 
 With ventana
  .Center
  .Caption = "Advertencia"
  .Width = 600
  .Height = 300
  .Border = False
 End With
 
 With boton1
  .Text = "Estoy seguro, anota"
  .x = 30
  .y = 150
  .Width = 200
  .Height = 50
 End With
 
 With boton2
  .Text = "No anotar"
  .x = 300
  .y = 150
  .Width = 150
  .Height = 50
 End With
 ventana.Show
 
End

Public Sub boton1_Click()
  
  Print "presionaste boton1"
  
End
Public Sub boton2_Click()
  
  Print "presionaste boton2"
  
End




 
v3ctor - Ver perfil del usuario Enviar mensaje privado  
v3ctor [ Viernes, 27 Junio 2014, 16:16 ]
Responder citando    Descargar mensaje  
Mensaje Re: Como Detectar Evento En Formulario Creado Por Código? 
 
v3ctor escribió: [Ver mensaje]

boton1 = New Button(ventana) As "boton1"
 boton2 = New Button(ventana) As "boton2"
 .....
 
End

Public Sub boton1_Click()
  
  Print "presionaste boton1"
  
End
Public Sub boton2_Click()
  
  Print "presionaste boton2"
  
End


Exactamente. Has atribuido cada boton a un su proprio unico grupo. Està bien.



 
última edición por vuott el Viernes, 27 Junio 2014, 16:19; editado 1 vez 
vuott - Ver perfil del usuario Enviar mensaje privado  
vuott [ Viernes, 27 Junio 2014, 16:18 ]
Mostrar mensajes anteriores:    
 
Publicar nuevo tema  Responder al tema  Página 1 de 1
 
 

Usuarios navegando en este tema: 0 registrados, 0 ocultos y 1 invitado
Usuarios registrados conectados: Ninguno


 



 

cron