千家信息网

VB.NET中ListView控件怎么用

发表于:2024-11-27 作者:千家信息网编辑
千家信息网最后更新 2024年11月27日,这篇文章主要介绍了VB.NET中ListView控件怎么用,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。VB.NET ListView
千家信息网最后更新 2024年11月27日VB.NET中ListView控件怎么用

这篇文章主要介绍了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控件怎么用"这篇文章对大家有帮助,同时也希望大家多多支持,关注行业资讯频道,更多相关知识等着你来学习!

0