?? form1.vb
字號:
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows 窗體設計器生成的代碼 "
Public Sub New()
MyBase.New()
'該調用是 Windows 窗體設計器所必需的。
InitializeComponent()
'在 InitializeComponent() 調用之后添加任何初始化
End Sub
'窗體重寫 dispose 以清理組件列表。
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
'Windows 窗體設計器所必需的
Private components As System.ComponentModel.IContainer
'注意: 以下過程是 Windows 窗體設計器所必需的
'可以使用 Windows 窗體設計器修改此過程。
'不要使用代碼編輯器修改它。
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents LB1 As System.Windows.Forms.ListBox
Friend WithEvents LB2 As System.Windows.Forms.ListBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.LB1 = New System.Windows.Forms.ListBox
Me.LB2 = New System.Windows.Forms.ListBox
Me.Button1 = New System.Windows.Forms.Button
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(16, 8)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(168, 32)
Me.Label1.TabIndex = 0
Me.Label1.Text = "選中城市后請雙擊"
'
'LB1
'
Me.LB1.ItemHeight = 12
Me.LB1.Location = New System.Drawing.Point(8, 48)
Me.LB1.Name = "LB1"
Me.LB1.Size = New System.Drawing.Size(176, 208)
Me.LB1.TabIndex = 1
'
'LB2
'
Me.LB2.ItemHeight = 12
Me.LB2.Location = New System.Drawing.Point(248, 48)
Me.LB2.Name = "LB2"
Me.LB2.Size = New System.Drawing.Size(168, 208)
Me.LB2.TabIndex = 2
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(24, 296)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(120, 24)
Me.Button1.TabIndex = 3
Me.Button1.Text = "添加"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(176, 296)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(160, 21)
Me.TextBox1.TabIndex = 4
Me.TextBox1.Text = ""
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(424, 374)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.LB2)
Me.Controls.Add(Me.LB1)
Me.Controls.Add(Me.Label1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
LB1.Items.Add("北京")
LB1.Items.Add("深圳")
LB1.Items.Add("昆明")
LB1.Items.Add("重慶")
LB1.Items.Add("天津")
LB1.Items.Add("上海")
End Sub
Private Sub LB1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles LB1.DoubleClick
If LB1.SelectedIndex >= 0 Then
LB2.Items.Add(LB1.SelectedItem.ToString)
LB1.Items.Remove(LB1.SelectedItem.ToString)
LB1.SelectedIndex = -1
Else
MessageBox.Show("請選擇一個城市", "錯誤")
End If
End Sub
Private Sub LB2_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles LB2.DoubleClick
If LB2.SelectedIndex >= 0 Then
LB1.Items.Add(LB2.SelectedItem.ToString)
LB2.Items.RemoveAt(LB2.SelectedIndex)
LB2.SelectedIndex = -1
Else
MessageBox.Show("請選擇一個城市", "錯誤")
End If
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
If TextBox1.Text = "" Then
Button1.Enabled = False
Else
Button1.Enabled = True
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text <> "" Then
If LB1.Items.Contains(TextBox1.Text) = False Then
LB1.Items.Add(TextBox1.Text)
TextBox1.Text = ""
End If
End If
End Sub
End Class
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -