您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
这篇文章主要介绍了VB.NET中ListView控件怎么用,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。
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.NET中ListView控件怎么用”这篇文章对大家有帮助,同时也希望大家多多支持亿速云,关注亿速云行业资讯频道,更多相关知识等着你来学习!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。