Principales respuestas
No doy con la tecla en este codigo

Pregunta
-
Buenas no doy con la tecla en este codigo
estoy intentando que cuando me ponga en lo alto del cada picturebox
me haga lo siguiente
Gracias
'CONTROLAR TODOS LOS PICTUREBOX Sub Recursivo(c As Control) For Each ctrl As Control In c.Controls If TypeOf ctrl Is PictureBox Or TypeOf ctrl Is Button Then AddHandler (ctrl.MouseEnter), AddressOf MouseEnter_All AddHandler (ctrl.MouseLeave), AddressOf MouseLeave_All Else Recursivo(ctrl) End If Next End Sub Public Shared TC As String Private Sub MouseEnter_All(sender As Object, e As System.EventArgs) Dim ctrl As Control = DirectCast(sender, Control) If TypeOf ctrl Is PictureBox Then TC = ctrl.Size = New Size(55, 62) TC = ctrl.BackColor = Color.LightSkyBlue ElseIf TypeOf ctrl Is Button Then End If End Sub Private Sub MouseLeave_All(sender As Object, e As System.EventArgs) Dim ctrl As Control = DirectCast(sender, Control) If TypeOf ctrl Is PictureBox Then TC = ctrl.Size = New Size(56, 63) TC = ctrl.BackColor = Color.Transparent ElseIf TypeOf ctrl Is Button Then End If End Sub 'CONTROLAR TODOS LOS PICTUREBOX
Respuestas
-
Supongo que lo que quieres es resaltar el control al poner el puntero del ratón sobre él.
Ten en cuenta que para que el tamaño de la imagen cambie en el picturebox debes asignar la propiedad SizeMode a StretchImage.Te sobra la variable TC y los procedimientos deben ser
Private Sub MouseEnter_All(sender As Object, e As System.EventArgs)
Dim ctrl As Control = DirectCast(sender, Control)
If TypeOf ctrl Is PictureBox Then
ctrl.Size = New Size(55, 562)
ctrl.BackColor = Color.LightSkyBlue
ElseIf TypeOf ctrl Is Button Then
End If
End Sub
Private Sub MouseLeave_All(sender As Object, e As System.EventArgs)
Dim ctrl As Control = DirectCast(sender, Control)
If TypeOf ctrl Is PictureBox Then
ctrl.Size = New Size(56, 63)
ctrl.BackColor = Color.Transparent
ElseIf TypeOf ctrl Is Button Then
End If
End SubSaludos, Javier J
- Marcado como respuesta JETET lunes, 20 de noviembre de 2017 15:01
Todas las respuestas
-
-
Supongo que lo que quieres es resaltar el control al poner el puntero del ratón sobre él.
Ten en cuenta que para que el tamaño de la imagen cambie en el picturebox debes asignar la propiedad SizeMode a StretchImage.Te sobra la variable TC y los procedimientos deben ser
Private Sub MouseEnter_All(sender As Object, e As System.EventArgs)
Dim ctrl As Control = DirectCast(sender, Control)
If TypeOf ctrl Is PictureBox Then
ctrl.Size = New Size(55, 562)
ctrl.BackColor = Color.LightSkyBlue
ElseIf TypeOf ctrl Is Button Then
End If
End Sub
Private Sub MouseLeave_All(sender As Object, e As System.EventArgs)
Dim ctrl As Control = DirectCast(sender, Control)
If TypeOf ctrl Is PictureBox Then
ctrl.Size = New Size(56, 63)
ctrl.BackColor = Color.Transparent
ElseIf TypeOf ctrl Is Button Then
End If
End SubSaludos, Javier J
- Marcado como respuesta JETET lunes, 20 de noviembre de 2017 15:01
-
Gracias por responder a todos
si tengo SizeMode a StretchImage
pero no me funciona
lo he puesto como tu me dices javier y nada
'CONTROLAR TODOS LOS PICTUREBOX Sub Recursivo(c As Control) For Each ctrl As Control In c.Controls If TypeOf ctrl Is PictureBox Then AddHandler (ctrl.MouseEnter), AddressOf MouseEnter_All AddHandler (ctrl.MouseLeave), AddressOf MouseLeave_All Else Recursivo(ctrl) End If Next End Sub Private Sub MouseEnter_All(sender As Object, e As System.EventArgs) Dim ctrl As Control = DirectCast(sender, Control) If TypeOf ctrl Is PictureBox Then ctrl.Size = New Size(55, 562) ctrl.BackColor = Color.LightSkyBlue End If End Sub Private Sub MouseLeave_All(sender As Object, e As System.EventArgs) Dim ctrl As Control = DirectCast(sender, Control) If TypeOf ctrl Is PictureBox Then ctrl.Size = New Size(56, 63) ctrl.BackColor = Color.Transparent End If End Sub 'CONTROLAR TODOS LOS PICTUREBOX
-
Doy por supuesto que tienes controles de tipo PictureBox.
Pon un punto de interrupción en MouseEnter_All para asegurarte de que se está ejecutando.Ten en cuenta que tal como tienes el código solo va a funcionar sobre controles picturebox porque aunque se llama al procedimiento también para botones luego en el código solo se aplica si es un picturebox.
Saludos, Javier J
-
-
-
nada de nada lo he puesto directamente en el sub del picture y si que se interrumpe
Public Class Form1 '' ''Private Sub PictureBox1_MouseLeave(sender As Object, e As EventArgs) Handles PictureBox1.MouseLeave '' '' PictureBox1.Size = New Size(56, 63) '' '' PictureBox1.BackColor = Color.Transparent '' ''End Sub '' ''Private Sub PictureBox1_MouseEnter(sender As Object, e As EventArgs) Handles PictureBox1.MouseEnter '' '' PictureBox1.Size = New Size(55, 62) '' '' PictureBox1.BackColor = Color.LightSkyBlue '' ''End Sub 'CONTROLAR TODOS LOS PICTUREBOX Sub Recursivo(c As Control) For Each ctrl As Control In c.Controls If TypeOf ctrl Is PictureBox Then AddHandler (ctrl.MouseEnter), AddressOf MouseEnter_All AddHandler (ctrl.MouseLeave), AddressOf MouseLeave_All Else Recursivo(ctrl) End If Next End Sub Private Sub MouseEnter_All(sender As Object, e As System.EventArgs) Dim ctrl As Control = DirectCast(sender, Control) If TypeOf ctrl Is PictureBox Then ctrl.Size = New Size(55, 562) ctrl.BackColor = Color.LightSkyBlue End If End Sub Private Sub MouseLeave_All(sender As Object, e As System.EventArgs) Dim ctrl As Control = DirectCast(sender, Control) If TypeOf ctrl Is PictureBox Then ctrl.Size = New Size(56, 63) ctrl.BackColor = Color.Transparent End If End Sub 'CONTROLAR TODOS LOS PICTUREBOX End Class
- Editado JETET lunes, 20 de noviembre de 2017 14:48
-
-
-
-