关于listbox控件的使用我已经做成了软件发到了网上,但是由于不支持.exe格式所以我改成了.gif的,朋友们可以下载下来,然后把后缀改成.exe就可以了
下载方法:
在上面的点击此处浏览图片就可以了。
原代码如下
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 ListBox1 As System.Windows.Forms.ListBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents LinkLabel1 As System.Windows.Forms.LinkLabel
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
Me.ListBox1 = New System.Windows.Forms.ListBox
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.Label1 = New System.Windows.Forms.Label
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.LinkLabel1 = New System.Windows.Forms.LinkLabel
Me.SuspendLayout()
'
'ListBox1
'
Me.ListBox1.ItemHeight = 12
Me.ListBox1.Items.AddRange(New Object() {"语文", "英语", "数学", "理化", "地理", "历史", "自然科学", "生物"})
Me.ListBox1.Location = New System.Drawing.Point(16, 16)
Me.ListBox1.MultiColumn = True
Me.ListBox1.Name = "ListBox1"
Me.ListBox1.Size = New System.Drawing.Size(384, 64)
Me.ListBox1.TabIndex = 0
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(40, 152)
Me.Button1.Name = "Button1"
Me.Button1.TabIndex = 1
Me.Button1.Text = "添加"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(280, 152)
Me.Button2.Name = "Button2"
Me.Button2.TabIndex = 2
Me.Button2.Text = "删除"
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Location = New System.Drawing.Point(16, 120)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(153, 17)
Me.Label1.TabIndex = 3
Me.Label1.Text = "请输入要添加或删除的选项"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(192, 120)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(192, 21)
Me.TextBox1.TabIndex = 4
Me.TextBox1.Text = ""
'
'LinkLabel1
'
Me.LinkLabel1.Cursor = System.Windows.Forms.Cursors.Cross
Me.LinkLabel1.Image = CType(resources.GetObject("LinkLabel1.Image"), System.Drawing.Image)
Me.LinkLabel1.LinkArea = New System.Windows.Forms.LinkArea(17, 34)
Me.LinkLabel1.Location = New System.Drawing.Point(96, 184)
Me.LinkLabel1.Name = "LinkLabel1"
Me.LinkLabel1.Size = New System.Drawing.Size(248, 104)
Me.LinkLabel1.TabIndex = 5
Me.LinkLabel1.TabStop = True
Me.LinkLabel1.Text = "本程序有影子计划师制作 常去的论坛http://bbs.bc-cn.net/bbs/index.asp Email:wlb.wlb@163.com"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(464, 301)
Me.Controls.Add(Me.LinkLabel1)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.ListBox1)
Me.Name = "Form1"
Me.Text = "ListBox控件的用法"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub button1_click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ListBox1.Items.Add("textbox1.text")
End Sub
Private Sub button2_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
ListBox1.Items.Remove(TextBox1.Text)
End Sub
Private Sub listbox1_selectedindexchanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
TextBox1.Text = ListBox1.SelectedItem
End Sub
Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
LinkLabel1.LinkVisited = True
System.Diagnostics.Process.Start("iexplore.exe", "http://bbs.bc-cn.net/")
End Sub
End Class
[此贴子已经被作者于2005-5-19 18:50:51编辑过]