ListBox.Items.RemoveAt : ListBox « System.Windows.Forms « VB.Net by API

Home
VB.Net by API
1.Microsoft.VisualBasic
2.Microsoft.Win32
3.System
4.System.Collections
5.System.Collections.Generic
6.System.Collections.Specialized
7.System.ComponentModel
8.System.Configuration.ConfigurationSettings
9.System.Data
10.System.Data.Odbc
11.System.Data.OleDb
12.System.Data.OracleClient
13.System.Data.SqlClient
14.System.Diagnostics
15.System.Drawing
16.System.Drawing.Drawing2D
17.System.Drawing.Imaging
18.System.Drawing.Printing
19.System.Drawing.Text
20.System.Globalization
21.System.IO
22.System.IO.IsolatedStorage
23.System.IO.Ports
24.System.Media
25.System.Messaging
26.System.Net
27.System.Net.Sockets
28.System.Reflection
29.System.Runtime.InteropServices
30.System.Runtime.Remoting.Channels
31.System.Runtime.Serialization
32.System.Runtime.Serialization.Formatters.Binary
33.System.Runtime.Serialization.Formatters.Soap
34.System.Security.Cryptography
35.System.Security.Cryptography.X509Certificates
36.System.Security.Permissions
37.System.Security.Principal
38.System.ServiceProcess
39.System.Text
40.System.Text.RegularExpressions
41.System.Threading
42.System.Web
43.System.Web.Mail
44.System.Windows.Forms
45.System.Xml
46.System.Xml.Schema
47.System.Xml.Serialization
48.System.Xml.Xsl
VB.Net
VB.Net Tutorial
VB.Net by API » System.Windows.Forms » ListBox 
ListBox.Items.RemoveAt
  

Imports System.Windows.Forms

public class DualList
   public Shared Sub Main
        Application.Run(New Form1)
   End Sub
End class

Public Class Form1

    Private Sub btnAddSource_Click(ByVal sender As System.Object, ByVal e As System.EventArgsHandles btnAddSource.Click
         lstSource.Items.Add("A")

    End Sub

    Private Sub btnAddDestination_Click(ByVal sender As System.Object, ByVal e As System.EventArgsHandles btnAddDestination.Click
         lstDestination.Items.Add("B")
    End Sub

    Private Sub btnClearSource_Click(ByVal sender As System.Object, ByVal e As System.EventArgsHandles btnClearSource.Click
        lstSource.Items.Clear()
    End Sub

    Private Sub btnClearDestination_Click(ByVal sender As System.Object, ByVal e As System.EventArgsHandles btnClearDestination.Click
        lstDestination.Items.Clear()
    End Sub

    Private Sub btnRemoveSource_Click(ByVal sender As System.Object, ByVal e As System.EventArgsHandles btnRemoveSource.Click

        If lstSource.SelectedItems.Count > Then
            lstSource.Items.Remove(lstSource.SelectedItem)
        End If

    End Sub

    Private Sub btnRemoveDestination_Click(ByVal sender As System.Object, ByVal e As System.EventArgsHandles btnRemoveDestination.Click

        Dim intCounter As Integer

        For intCounter = To lstDestination.SelectedIndices.Count - 1
            lstDestination.Items.RemoveAt(lstDestination.SelectedIndices(0))
        Next intCounter

    End Sub

    Private Sub btnMoveDestination_Click(ByVal sender As System.Object, ByVal e As System.EventArgsHandles btnMoveDestination.Click
        If lstSource.SelectedItems.Count > Then
            lstDestination.Items.Add(lstSource.SelectedItem)
            lstSource.Items.RemoveAt(lstSource.SelectedIndex)
        End If
    End Sub

    Private Sub btnMoveSource_Click(ByVal sender As System.Object, ByVal e As System.EventArgsHandles btnMoveSource.Click

        Dim intCounter As Integer

        For intCounter = To lstDestination.SelectedIndices.Count - 1
            lstSource.Items.Add(lstDestination.Items(lstDestination.SelectedIndices(0)))
            lstDestination.Items.Remove(lstDestination.Items(lstDestination.SelectedIndices(0)))
        Next intCounter

    End Sub

    Private Sub btnMoveAllDestination_Click(ByVal sender As System.Object, ByVal e As System.EventArgsHandles btnMoveAllDestination.Click

        Dim intCounter As Integer

        For intCounter = To lstSource.Items.Count - 1
            lstDestination.Items.Add(lstSource.Items(0))
            lstSource.Items.RemoveAt(0)
        Next intCounter

    End Sub

    Private Sub btnMoveAllSource_Click(ByVal sender As System.Object, ByVal e As System.EventArgsHandles btnMoveAllSource.Click

        Dim intCounter As Integer

        For intCounter = To lstDestination.Items.Count - 1
            lstSource.Items.Add(lstDestination.Items(0))
            lstDestination.Items.RemoveAt(0)
        Next intCounter

    End Sub
End Class
Partial Public Class Form1
    Inherits System.Windows.Forms.Form

    <System.Diagnostics.DebuggerNonUserCode()> _
    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

    End Sub

    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing AndAlso components IsNot Nothing Then
            components.Dispose()
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.lstSource = New System.Windows.Forms.ListBox
        Me.lstDestination = New System.Windows.Forms.ListBox
        Me.btnMoveAllDestination = New System.Windows.Forms.Button
        Me.btnMoveDestination = New System.Windows.Forms.Button
        Me.btnMoveSource = New System.Windows.Forms.Button
        Me.btnMoveAllSource = New System.Windows.Forms.Button
        Me.btnAddSource = New System.Windows.Forms.Button
        Me.btnRemoveSource = New System.Windows.Forms.Button
        Me.btnClearSource = New System.Windows.Forms.Button
        Me.btnAddDestination = New System.Windows.Forms.Button
        Me.btnRemoveDestination = New System.Windows.Forms.Button
        Me.btnClearDestination = New System.Windows.Forms.Button
        Me.Label1 = New System.Windows.Forms.Label
        Me.Label2 = New System.Windows.Forms.Label
        Me.SuspendLayout()
        '
        'lstSource
        '
        Me.lstSource.FormattingEnabled = True
        Me.lstSource.Location = New System.Drawing.Point(2125)
        Me.lstSource.Name = "lstSource"
        Me.lstSource.Size = New System.Drawing.Size(162199)
        Me.lstSource.TabIndex = 0
        '
        'lstDestination
        '
        Me.lstDestination.FormattingEnabled = True
        Me.lstDestination.Location = New System.Drawing.Point(25425)
        Me.lstDestination.Name = "lstDestination"
        Me.lstDestination.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended
        Me.lstDestination.Size = New System.Drawing.Size(162199)
        Me.lstDestination.Sorted = True
        Me.lstDestination.TabIndex = 1
        '
        'btnMoveAllDestination
        '
        Me.btnMoveAllDestination.Location = New System.Drawing.Point(20148)
        Me.btnMoveAllDestination.Name = "btnMoveAllDestination"
        Me.btnMoveAllDestination.Size = New System.Drawing.Size(3628)
        Me.btnMoveAllDestination.TabIndex = 2
        Me.btnMoveAllDestination.Text = ">>"
        '
        'btnMoveDestination
        '
        Me.btnMoveDestination.Location = New System.Drawing.Point(20183)
        Me.btnMoveDestination.Name = "btnMoveDestination"
        Me.btnMoveDestination.Size = New System.Drawing.Size(3628)
        Me.btnMoveDestination.TabIndex = 3
        Me.btnMoveDestination.Text = ">"
        '
        'btnMoveSource
        '
        Me.btnMoveSource.Location = New System.Drawing.Point(201141)
        Me.btnMoveSource.Name = "btnMoveSource"
        Me.btnMoveSource.Size = New System.Drawing.Size(3628)
        Me.btnMoveSource.TabIndex = 4
        Me.btnMoveSource.Text = "<"
        '
        'btnMoveAllSource
        '
        Me.btnMoveAllSource.Location = New System.Drawing.Point(201176)
        Me.btnMoveAllSource.Name = "btnMoveAllSource"
        Me.btnMoveAllSource.Size = New System.Drawing.Size(3628)
        Me.btnMoveAllSource.TabIndex = 5
        Me.btnMoveAllSource.Text = "<<"
        '
        'btnAddSource
        '
        Me.btnAddSource.Location = New System.Drawing.Point(21237)
        Me.btnAddSource.Name = "btnAddSource"
        Me.btnAddSource.Size = New System.Drawing.Size(16124)
        Me.btnAddSource.TabIndex = 6
        Me.btnAddSource.Text = "Add Item"
        '
        'btnRemoveSource
        '
        Me.btnRemoveSource.Location = New System.Drawing.Point(22268)
        Me.btnRemoveSource.Name = "btnRemoveSource"
        Me.btnRemoveSource.Size = New System.Drawing.Size(16124)
        Me.btnRemoveSource.TabIndex = 7
        Me.btnRemoveSource.Text = "Remove Item"
        '
        'btnClearSource
        '
        Me.btnClearSource.Location = New System.Drawing.Point(22299)
        Me.btnClearSource.Name = "btnClearSource"
        Me.btnClearSource.Size = New System.Drawing.Size(16124)
        Me.btnClearSource.TabIndex = 8
        Me.btnClearSource.Text = "Clear Items"
        '
        'btnAddDestination
        '
        Me.btnAddDestination.Location = New System.Drawing.Point(254237)
        Me.btnAddDestination.Name = "btnAddDestination"
        Me.btnAddDestination.Size = New System.Drawing.Size(16124)
        Me.btnAddDestination.TabIndex = 9
        Me.btnAddDestination.Text = "Add Item"
        '
        'btnRemoveDestination
        '
        Me.btnRemoveDestination.Location = New System.Drawing.Point(254268)
        Me.btnRemoveDestination.Name = "btnRemoveDestination"
        Me.btnRemoveDestination.Size = New System.Drawing.Size(16124)
        Me.btnRemoveDestination.TabIndex = 10
        Me.btnRemoveDestination.Text = "Remove Item(s)"
        '
        'btnClearDestination
        '
        Me.btnClearDestination.Location = New System.Drawing.Point(254299)
        Me.btnClearDestination.Name = "btnClearDestination"
        Me.btnClearDestination.Size = New System.Drawing.Size(16124)
        Me.btnClearDestination.TabIndex = 11
        Me.btnClearDestination.Text = "Clear Items"
        '
        'Label1
        '
        Me.Label1.AutoSize = True
        Me.Label1.Location = New System.Drawing.Point(206)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(7414)
        Me.Label1.TabIndex = 12
        Me.Label1.Text = "Unsorted List:"
        '
        'Label2
        '
        Me.Label2.AutoSize = True
        Me.Label2.Location = New System.Drawing.Point(2546)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(6114)
        Me.Label2.TabIndex = 13
        Me.Label2.Text = "Sorted List:"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(513)
        Me.ClientSize = New System.Drawing.Size(438340)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.btnClearDestination)
        Me.Controls.Add(Me.btnRemoveDestination)
        Me.Controls.Add(Me.btnAddDestination)
        Me.Controls.Add(Me.btnClearSource)
        Me.Controls.Add(Me.btnRemoveSource)
        Me.Controls.Add(Me.btnAddSource)
        Me.Controls.Add(Me.btnMoveAllSource)
        Me.Controls.Add(Me.btnMoveSource)
        Me.Controls.Add(Me.btnMoveDestination)
        Me.Controls.Add(Me.btnMoveAllDestination)
        Me.Controls.Add(Me.lstDestination)
        Me.Controls.Add(Me.lstSource)
        Me.Name = "Form1"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "ListDemo"
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub
    Friend WithEvents lstSource As System.Windows.Forms.ListBox
    Friend WithEvents lstDestination As System.Windows.Forms.ListBox
    Friend WithEvents btnMoveAllDestination As System.Windows.Forms.Button
    Friend WithEvents btnMoveDestination As System.Windows.Forms.Button
    Friend WithEvents btnMoveSource As System.Windows.Forms.Button
    Friend WithEvents btnMoveAllSource As System.Windows.Forms.Button
    Friend WithEvents btnAddSource As System.Windows.Forms.Button
    Friend WithEvents btnRemoveSource As System.Windows.Forms.Button
    Friend WithEvents btnClearSource As System.Windows.Forms.Button
    Friend WithEvents btnAddDestination As System.Windows.Forms.Button
    Friend WithEvents btnRemoveDestination As System.Windows.Forms.Button
    Friend WithEvents btnClearDestination As System.Windows.Forms.Button
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label

End Class

   
    
  
Related examples in the same category
1.ListBox.DataSource
2.ListBox.DisplayMember
3.ListBox.DoDragDrop
4.ListBox.DoubleClick
5.ListBox.DragDrop
6.ListBox.DragEnter
7.ListBox.DragLeave
8.ListBox.DragOver
9.ListBox.DrawMode
10.ListBox.IndexFromPoint
11.ListBox.ItemHeight
12.ListBox.Items.Add
13.ListBox.Items.Clear()
14.ListBox.Items.Remove
15.ListBox.MeasureItem
16.ListBox.MouseDown
17.ListBox.PointToClient
18.ListBox.SelectedIndexChanged
19.ListBox.SelectedIndices
20.ListBox.SelectionMode
21.ListBox.SetSelected
22.ListBox.TopIndex
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.