本文向大家介绍VB.NET ListView控件,可能好多人还不了解VB.NET ListView控件,没有关系,看完本文你肯定有不少收获,希望本文能教会你更多东西。
创新互联建站10多年企业网站制作服务;为您提供网站建设,网站制作,网页设计及高端网站定制服务,企业网站制作及推广,对宣传片制作等多个行业拥有多年的网站运维经验的网站建设公司。
VB.NET ListView控件在程序开发过程中的使用是非常广泛的。因为其不支持数据库的绑定,所以在数据库程序开发领域无法与datagridview抗衡,但是ListView的确是一个非常好用的控件。下面就把一个简单的VB.NET ListView控件的例子发出来。
- Public Class heroClass hero
- Private s_name As String
- Private s_age As Long
- Private s_like As String
- Public Property myName()Property myName() As String
- Get
- Return s_name
- End Get
- Set(ByVal value As String)
- s_name = value
- End Set
- End Property
- Public Property myAge()Property myAge() As Long
- Get
- Return s_age
- End Get
- Set(ByVal value As Long)
- s_age = value
- End Set
- End Property
- Public Property myLike()Property myLike() As String
- Get
- Return s_like
- End Get
- Set(ByVal value As String)
- s_like = value
- End Set
- End Property
- End Class
VB.NET ListView控件装载数据
- Private Sub btnLoad_Click()Sub btnLoad_Click(ByVal sender As
- System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click
- s_flag = True
- Me.lv1.CheckBoxes = True
- Dim i As Integer
- Const maxCount As Long = 10
- Dim iItem As ListViewItem
- Dim aHero As hero
- For i = maxNumber To maxNumber + maxCount - 1
- Dim rd As New System.Random(Environment.TickCount * i)
- aHero = New her
- iItem = New ListViewItem
- aHero.myName = firstName & i.ToString
- aHero.myAge = System.Math.Round(rd.NextDouble * 100, 0)
- aHero.myLike = createLike(i)
- iItem.Text = aHero.myName
- iItem.Tag = aHero
- iItem.SubItems.Add(aHero.myAge)
- iItem.SubItems.Add(aHero.myLike)
- Me.lv1.Items.Add(iItem)
- heroList.Add(aHero.myName, aHero)
- Next
- maxNumber = i
- If Me.lv1.Items.Count > 0 Then
- Me.lv1.Items.Item(0).Checked = True
- End If
- s_flag = False
- End Sub
分享标题:VB.NETListView控件经验总结
文章转载:http://www.stwzsj.com/qtweb/news43/16343.html
网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联