Visual Basic.NET - listbox

 
Vista:

listbox

Publicado por aritz amezaga (16 intervenciones) el 23/11/2007 12:46:08
hola, necesito saber como pasar un elemento seleccionado en un listbox1 a un listbox2 al pulsar en un boton.

muchas gracias.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:listbox

Publicado por kryptic (40 intervenciones) el 23/11/2007 15:06:46
Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For i As Integer = 0 To 4
ListBox1.Items.Add("Elemento " & i)
Next
End Sub

Private Sub btnEliminar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEliminar.Click
If Not ListBox1.SelectedIndex = -1 Then
ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
End If

If Not ListBox2.SelectedIndex = -1 Then
ListBox2.Items.RemoveAt(ListBox2.SelectedIndex)
End If
End Sub

Private Sub btnPasar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPasar.Click
If Not ListBox1.SelectedIndex = -1 Then
Dim temp As String = ListBox1.SelectedItem.ToString
ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
ListBox2.Items.Add(temp)
End If

If Not ListBox2.SelectedIndex = -1 Then
Dim temp As String = ListBox2.SelectedItem.ToString
ListBox2.Items.RemoveAt(ListBox2.SelectedIndex)
ListBox1.Items.Add(temp)
End If
End Sub
End Class
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar