Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use ListView Control in VB.NET

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces how to use the ListView control in VB.NET, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand.

VB.NET ListView controls are widely used in the process of program development. Because it does not support database binding, it can not compete with datagridview in the field of database program development, but ListView is indeed a very useful control. Here is an example of a simple VB.NET ListView control.

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 control loads data

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 Thank you for reading this article carefully I hope the article "how to use ListView controls in VB.NET" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report