您好,登錄后才能下訂單哦!
這篇文章主要介紹了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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。