Select From Available List Box to Selected List Box
List Box1 > List Box2 ---btn_select(>)
List Box1 > > List Box2 ----btn_select_all(>>)
List Box1 < List Box2----btn_remove(<<)
List Box1 << List Box2 ----btn_remove_all(<<)
Code behind code :
Protected Sub btn_select_Click(sender As Object, e As EventArgs) Handles btn_select.Click
Try
tran_min_det_1 = New ArrayList
If lst_Transaction.SelectedIndex >= 0 Then
For i As Integer = 0 To lst_Transaction.Items.Count - 1
If lst_Transaction.Items(i).Selected Then
If Not tran_min_det_1.Contains(lst_Transaction.Items(i)) Then
tran_min_det_1.Add(lst_Transaction.Items(i))
End If
End If
Next
For i As Integer = 0 To tran_min_det_1.Count - 1
If Not lst_Seleted_Transaction.Items.Contains(DirectCast(tran_min_det_1(i), System.Web.UI.WebControls.ListItem)) Then
lst_Seleted_Transaction.Items.Add(DirectCast(tran_min_det_1(i), System.Web.UI.WebControls.ListItem))
End If
lst_Transaction.Items.Remove(DirectCast(tran_min_det_1(i), System.Web.UI.WebControls.ListItem))
Next
lst_Seleted_Transaction.SelectedIndex = -1
Else
returnErrorMsg("Please select atleast one in Transaction List to move")
Exit Sub
End If
Catch ex As Exception
End Try
End Sub
Protected Sub btn_select_all_Click(sender As Object, e As EventArgs) Handles btn_select_all.Click
Try
While lst_Transaction.Items.Count <> 0
Dim i As Integer
For i = 0 To lst_Transaction.Items.Count - 1
lst_Seleted_Transaction.Items.Add(lst_Transaction.Items(i))
Next
While i > 0
lst_Transaction.Items.Remove(lst_Transaction.Items(i - 1))
i = i - 1
End While
End While
returnErrorMsg("")
Catch ex As Exception
End Try
End Sub
Protected Sub btn_remove_Click(sender As Object, e As EventArgs) Handles btn_remove.Click
Try
tran_min_det_2 = New ArrayList
If lst_Seleted_Transaction.SelectedIndex >= 0 Then
For i As Integer = 0 To lst_Seleted_Transaction.Items.Count - 1
If lst_Seleted_Transaction.Items(i).Selected Then
If Not tran_min_det_2.Contains(lst_Seleted_Transaction.Items(i)) Then
tran_min_det_2.Add(lst_Seleted_Transaction.Items(i))
End If
End If
Next
For i As Integer = 0 To tran_min_det_2.Count - 1
If Not lst_Transaction.Items.Contains(DirectCast(tran_min_det_2(i), System.Web.UI.WebControls.ListItem)) Then
lst_Transaction.Items.Add(DirectCast(tran_min_det_2(i), System.Web.UI.WebControls.ListItem))
End If
lst_Seleted_Transaction.Items.Remove(DirectCast(tran_min_det_2(i), System.Web.UI.WebControls.ListItem))
Next
lst_Transaction.SelectedIndex = -1
Else
returnErrorMsg("Please select atleast one in Available Field List to move")
Exit Sub
End If
Catch ex As Exception
End Try
End Sub
Protected Sub btn_remove_all_Click(sender As Object, e As EventArgs) Handles btn_remove_all.Click
Try
While lst_Seleted_Transaction.Items.Count <> 0
Dim i As Integer
For i = 0 To lst_Seleted_Transaction.Items.Count - 1
Me.lst_Transaction.Items.Add(lst_Seleted_Transaction.Items(i))
Next
While i > 0
Me.lst_Seleted_Transaction.Items.Remove(lst_Seleted_Transaction.Items(i - 1))
i = i - 1
End While
End While
returnErrorMsg("")
' Exit Sub
Catch ex As Exception
End Try
End Sub