como pasar de un listbox1 a un listbox2 itemns
para ello crearemos:
2; listBox
7 ; Button "respectivamente >>,>,<<,< añadir,eliminar, button"organizar"
1; textbox1
2 ; label "quienes mostraran el numero de items que estén registrados en los listbox"
Public Class Form1
Private Const msgbox_Eliminar As String = "Para eliminar un dato, debe seleccionarlo previamente"
Private Const msgbox_Pasar_Dato As String = "Para pasar un dato, debe seleccionarlo previamente"
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
With ListBox1
.Items.Add("Footbal")
.Items.Add("Tenis")
.Items.Add("Baloncesto")
.Items.Add("Rana")
.Items.Add("Tejo")
.Items.Add("Natación")
.Items.Add("Atletismo")
End With
Label1.Text = ListBox1.Items.Count & " elemento(s)"
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button5.Click
If TextBox1.Text <> "" Then
End If
ListBox1.Items.Add(TextBox1.Text)
Label1.Text = ListBox1.Items.Count & " elemento(s)"
TextBox1.Text = ""
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
If ListBox1.SelectedIndex <> -1 Then
ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
Label1.Text = ListBox1.Items.Count & " elemento(s)"
Else
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
While ListBox1.Items.Count > 0
ListBox1.SelectedIndex = ListBox1.Items.Count - 1
ListBox2.Items.Add(ListBox1.SelectedItem)
ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
End While
Label1.Text = ListBox1.Items.Count & " elemento(s)"
Label2.Text = ListBox2.Items.Count & " elemento(s)"
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
While ListBox2.Items.Count > 0
ListBox2.SelectedIndex = ListBox2.Items.Count - 1
ListBox1.Items.Add(ListBox2.SelectedItem)
ListBox2.Items.RemoveAt(ListBox2.SelectedIndex)
End While
Label1.Text = ListBox1.Items.Count & " elemento(s)"
Label2.Text = ListBox2.Items.Count & " elemento(s)"
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
If ListBox1.SelectedIndex <> -1 Then
ListBox2.Items.Add(ListBox1.SelectedItem)
ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
Label1.Text = ListBox1.Items.Count & " elemento(s)"
Label2.Text = ListBox2.Items.Count & " elemento(s)"
Else
If ListBox1.Items.Count > 0 Then
End If
End If
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
ListBox2.Sorted = True
ListBox2.Sorted = False
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If ListBox2.SelectedIndex <> -1 Then
ListBox1.Items.Add(ListBox2.SelectedItem)
ListBox2.Items.RemoveAt(ListBox2.SelectedIndex)
Label1.Text = ListBox1.Items.Count & " elemento(s)"
Label2.Text = ListBox2.Items.Count & " elemento(s)"
Else
If ListBox2.Items.Count > 0 Then
End If
End If
End Sub