VideoCurso 11 VB.NET - Picturebox (Caja de Imagenes)


En este nuevo curso de visual studio veremos el uso de el picture box su funcion principal es la de mostrar imagenes vamoa a trabajar tambien con el uso de el combobox algo que ya hemos visto anteriormente para este ejercicio seguiremos trabajando con el msn .


Video Curso





Codigo fuente






Private Sub cbestado_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbestado.SelectedIndexChanged

'SI HE SELECCIONADO DISPONIBLE NOS MUSTRE EL PICTURE BOX DISPONIBLE


If cbestado.SelectedItem = "Disponible" Then
pbdisponible.Visible = True
pbausente.Visible = False
pbocupado.Visible = False
pbsinconexion.Visible = False
End If


'SI HE SELECCIONADO AUSENTE NOS MUSTRE EL PICTURE BOX AUSENTE

If cbestado.SelectedItem = "Ausente" Then
pbausente.Visible = True
pbdisponible.Visible = False
pbocupado.Visible = False
pbsinconexion.Visible = False
End If


'SI HE SELECCIONADO OCUPADO NOS MUSTRE EL PICTURE BOX OCUPADO

If cbestado.SelectedItem = "Ocupado" Then
pbocupado.Visible = True
pbausente.Visible = False
pbdisponible.Visible = False
pbsinconexion.Visible = False
End If


'SI HE SELECCIONADO SINCONEXION NOS MUSTRE EL PICTURE BOX SINCONEXION

If cbestado.SelectedItem = "Aparece sin conexion" Then
pbsinconexion.Visible = True
pbocupado.Visible = False
pbausente.Visible = False
pbdisponible.Visible = False
End If


End Sub

2 comentarios :

  1. creo q con este codigo quedaría mejor amigo, y con un solo picture box

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

    If ComboBox1.SelectedItem = "Disponible" Then
    PictureBox1.Image = My.Resources.disponible

    ElseIf ComboBox1.SelectedItem = "Ausente" Then
    PictureBox1.Image = My.Resources.ausente

    ElseIf ComboBox1.SelectedItem = "Ocupado" Then
    PictureBox1.Image = My.Resources.ocupado

    ElseIf ComboBox1.SelectedItem = "Sin Conexion" Then
    PictureBox1.Image = My.Resources.sinconexion
    End If
    End Sub

    ResponderEliminar
  2. ESTE SEGUNDO CODIGO QUE DIO EL ANONIMO ME FUNCIONO PERFECTAMENTE Y ES MAS FACIL DE MANEJAR,Y PUSE LAS LABRAS EN EL COMBOBOX SIN USAR CODIGO ,IGUAL FUNCIONO MUY BIEN GRACIAS ,NO LO LOGRARIA SIN USTEDES...

    ResponderEliminar

Seguidores