您好,登錄后才能下訂單哦!
這篇文章主要介紹了VB.NET中ListView控件怎么用,具有一定借鑒價(jià)值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。
VB.NET ListView控件在程序開發(fā)過程中的使用是非常廣泛的。因?yàn)槠洳恢С謹(jǐn)?shù)據(jù)庫的綁定,所以在數(shù)據(jù)庫程序開發(fā)領(lǐng)域無法與datagridview抗衡,但是ListView的確是一個非常好用的控件。下面就把一個簡單的VB.NET ListView控件的例子發(fā)出來。
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控件裝載數(shù)據(jù)
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
感謝你能夠認(rèn)真閱讀完這篇文章,希望小編分享的“VB.NET中ListView控件怎么用”這篇文章對大家有幫助,同時(shí)也希望大家多多支持億速云,關(guān)注億速云行業(yè)資訊頻道,更多相關(guān)知識等著你來學(xué)習(xí)!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。