📄 form1.vb
字号:
Option Strict On
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
Friend WithEvents bttnAdd1 As System.Windows.Forms.Button
Friend WithEvents btttnAdd2 As System.Windows.Forms.Button
Friend WithEvents bttnClearLeft As System.Windows.Forms.Button
Friend WithEvents bttnClear2 As System.Windows.Forms.Button
Friend WithEvents sourceList As System.Windows.Forms.ListBox
Friend WithEvents destinationList As System.Windows.Forms.ListBox
Friend WithEvents bttnMoveAllDest As System.Windows.Forms.Button
Friend WithEvents bttnMoveDest As System.Windows.Forms.Button
Friend WithEvents bttnMoveSrc As System.Windows.Forms.Button
Friend WithEvents bttnMoveAllSrc As System.Windows.Forms.Button
Friend WithEvents bttnRemoveSelSrc As System.Windows.Forms.Button
Friend WithEvents bttnRemoveSelDest As System.Windows.Forms.Button
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
'Required by the Windows Form Designer
Private components As System.ComponentModel.Container
'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.sourceList = New System.Windows.Forms.ListBox()
Me.bttnMoveDest = New System.Windows.Forms.Button()
Me.bttnMoveAllSrc = New System.Windows.Forms.Button()
Me.destinationList = New System.Windows.Forms.ListBox()
Me.Label1 = New System.Windows.Forms.Label()
Me.Label2 = New System.Windows.Forms.Label()
Me.bttnAdd1 = New System.Windows.Forms.Button()
Me.bttnRemoveSelDest = New System.Windows.Forms.Button()
Me.bttnClear2 = New System.Windows.Forms.Button()
Me.bttnClearLeft = New System.Windows.Forms.Button()
Me.bttnMoveAllDest = New System.Windows.Forms.Button()
Me.btttnAdd2 = New System.Windows.Forms.Button()
Me.bttnMoveSrc = New System.Windows.Forms.Button()
Me.bttnRemoveSelSrc = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'sourceList
'
Me.sourceList.DisplayMember = "G"
Me.sourceList.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.sourceList.ItemHeight = 14
Me.sourceList.Location = New System.Drawing.Point(8, 24)
Me.sourceList.Name = "sourceList"
Me.sourceList.SelectionMode = System.Windows.Forms.SelectionMode.MultiSimple
Me.sourceList.Size = New System.Drawing.Size(176, 200)
Me.sourceList.TabIndex = 0
Me.sourceList.ValueMember = "G"
'
'bttnMoveDest
'
Me.bttnMoveDest.Font = New System.Drawing.Font("Tahoma", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.bttnMoveDest.Location = New System.Drawing.Point(192, 88)
Me.bttnMoveDest.Name = "bttnMoveDest"
Me.bttnMoveDest.Size = New System.Drawing.Size(40, 32)
Me.bttnMoveDest.TabIndex = 2
Me.bttnMoveDest.Text = ">"
'
'bttnMoveAllSrc
'
Me.bttnMoveAllSrc.Font = New System.Drawing.Font("Tahoma", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.bttnMoveAllSrc.Location = New System.Drawing.Point(192, 176)
Me.bttnMoveAllSrc.Name = "bttnMoveAllSrc"
Me.bttnMoveAllSrc.Size = New System.Drawing.Size(40, 32)
Me.bttnMoveAllSrc.TabIndex = 2
Me.bttnMoveAllSrc.Text = "<<"
'
'destinationList
'
Me.destinationList.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.destinationList.ItemHeight = 14
Me.destinationList.Location = New System.Drawing.Point(248, 24)
Me.destinationList.Name = "destinationList"
Me.destinationList.Size = New System.Drawing.Size(176, 200)
Me.destinationList.Sorted = True
Me.destinationList.TabIndex = 1
'
'Label1
'
Me.Label1.Font = New System.Drawing.Font("Verdana", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.Location = New System.Drawing.Point(8, 0)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(176, 23)
Me.Label1.TabIndex = 4
Me.Label1.Text = "Unsorted List"
Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Label2
'
Me.Label2.Font = New System.Drawing.Font("Verdana", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label2.Location = New System.Drawing.Point(248, 0)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(176, 23)
Me.Label2.TabIndex = 4
Me.Label2.Text = "Sorted List"
Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'bttnAdd1
'
Me.bttnAdd1.Font = New System.Drawing.Font("Verdana", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.bttnAdd1.Location = New System.Drawing.Point(8, 232)
Me.bttnAdd1.Name = "bttnAdd1"
Me.bttnAdd1.Size = New System.Drawing.Size(176, 32)
Me.bttnAdd1.TabIndex = 3
Me.bttnAdd1.Text = "Add Item"
'
'bttnRemoveSelDest
'
Me.bttnRemoveSelDest.Font = New System.Drawing.Font("Verdana", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.bttnRemoveSelDest.Location = New System.Drawing.Point(248, 264)
Me.bttnRemoveSelDest.Name = "bttnRemoveSelDest"
Me.bttnRemoveSelDest.Size = New System.Drawing.Size(176, 32)
Me.bttnRemoveSelDest.TabIndex = 3
Me.bttnRemoveSelDest.Text = "Remove Selected Item"
'
'bttnClear2
'
Me.bttnClear2.Font = New System.Drawing.Font("Verdana", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.bttnClear2.Location = New System.Drawing.Point(248, 296)
Me.bttnClear2.Name = "bttnClear2"
Me.bttnClear2.Size = New System.Drawing.Size(176, 32)
Me.bttnClear2.TabIndex = 3
Me.bttnClear2.Text = "Clear"
'
'bttnClearLeft
'
Me.bttnClearLeft.Font = New System.Drawing.Font("Verdana", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.bttnClearLeft.Location = New System.Drawing.Point(8, 296)
Me.bttnClearLeft.Name = "bttnClearLeft"
Me.bttnClearLeft.Size = New System.Drawing.Size(176, 32)
Me.bttnClearLeft.TabIndex = 3
Me.bttnClearLeft.Text = "Clear"
'
'bttnMoveAllDest
'
Me.bttnMoveAllDest.Font = New System.Drawing.Font("Tahoma", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.bttnMoveAllDest.Location = New System.Drawing.Point(192, 48)
Me.bttnMoveAllDest.Name = "bttnMoveAllDest"
Me.bttnMoveAllDest.Size = New System.Drawing.Size(40, 32)
Me.bttnMoveAllDest.TabIndex = 2
Me.bttnMoveAllDest.Text = ">>"
'
'btttnAdd2
'
Me.btttnAdd2.Font = New System.Drawing.Font("Verdana", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.btttnAdd2.Location = New System.Drawing.Point(248, 232)
Me.btttnAdd2.Name = "btttnAdd2"
Me.btttnAdd2.Size = New System.Drawing.Size(176, 32)
Me.btttnAdd2.TabIndex = 3
Me.btttnAdd2.Text = "Add Item"
'
'bttnMoveSrc
'
Me.bttnMoveSrc.Font = New System.Drawing.Font("Tahoma", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.bttnMoveSrc.Location = New System.Drawing.Point(192, 128)
Me.bttnMoveSrc.Name = "bttnMoveSrc"
Me.bttnMoveSrc.Size = New System.Drawing.Size(40, 32)
Me.bttnMoveSrc.TabIndex = 2
Me.bttnMoveSrc.Text = "<"
'
'bttnRemoveSelSrc
'
Me.bttnRemoveSelSrc.Font = New System.Drawing.Font("Verdana", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.bttnRemoveSelSrc.Location = New System.Drawing.Point(8, 264)
Me.bttnRemoveSelSrc.Name = "bttnRemoveSelSrc"
Me.bttnRemoveSelSrc.Size = New System.Drawing.Size(176, 32)
Me.bttnRemoveSelSrc.TabIndex = 3
Me.bttnRemoveSelSrc.Text = "Remove Selected Items"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(432, 341)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label2, Me.Label1, Me.bttnRemoveSelDest, Me.bttnRemoveSelSrc, Me.bttnClear2, Me.bttnClearLeft, Me.btttnAdd2, Me.bttnAdd1, Me.bttnMoveAllSrc, Me.bttnMoveSrc, Me.bttnMoveDest, Me.bttnMoveAllDest, Me.destinationList, Me.sourceList})
Me.Name = "Form1"
Me.Text = "ListBox Demo"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub btttnAdd2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btttnAdd2.Click
Dim ListItem As String
ListItem = InputBox("Enter new item's name")
If ListItem.Trim <> "" Then
destinationList.Items.Add(ListItem)
End If
End Sub
Private Sub bttnAdd1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnAdd1.Click
Dim ListItem As String
ListItem = InputBox("Enter new item's name")
If ListItem.Trim <> "" Then
sourceList.Items.Add(ListItem)
End If
End Sub
Private Sub bttnRemoveSelDest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnRemoveSelDest.Click
If destinationList.SelectedItems.Count > 0 Then
destinationList.Items.Remove(destinationList.SelectedItem)
End If
End Sub
Private Sub bttnRemoveSelSrc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnRemoveSelSrc.Click
Dim i As Integer
For i = 0 To sourceList.SelectedIndices.Count - 1
sourceList.Items.RemoveAt(sourceList.SelectedIndices(0))
Next
End Sub
Private Sub bttnMoveSrc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnMoveSrc.Click
If destinationList.SelectedItems.Count > 0 Then
sourceList.Items.Add(destinationList.SelectedItem)
destinationList.Items.RemoveAt(destinationList.SelectedIndex)
End If
End Sub
Private Sub bttnMoveAllDest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnMoveAllDest.Click
Dim i As Integer
For i = 0 To sourceList.Items.Count - 1
destinationList.Items.Add(sourceList.Items(0))
sourceList.Items.RemoveAt(0)
Next
End Sub
Private Sub bttnMoveDest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnMoveDest.Click
Dim i As Integer
For i = 0 To sourceList.SelectedIndices.Count - 1
destinationList.Items.Add(sourceList.Items(sourceList.SelectedIndices(0)))
sourceList.Items.Remove(sourceList.Items(sourceList.SelectedIndices(0)))
Next
End Sub
Private Sub bttnClearLeft_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnClearLeft.Click
sourceList.Items.Clear()
End Sub
Private Sub bttnClear2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnClear2.Click
destinationList.Items.Clear()
End Sub
Private Sub bttnMoveAllSrc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnMoveAllSrc.Click
Dim i As Integer
For i = 0 To destinationList.Items.Count - 1
sourceList.Items.Add(destinationList.Items(0))
destinationList.Items.RemoveAt(0)
Next
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -