Advertisement
binjeeclick

list

Dec 3rd, 2018
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.20 KB | None | 0 0
  1. Public Class Form1
  2.  
  3.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  4.         ''Set view property
  5.         ListView1.View = View.Details
  6.         ListView1.GridLines = True
  7.         ListView1.FullRowSelect = True
  8.  
  9.         'Add column header
  10.         ListView1.Columns.Add("ProductName", 100)
  11.         ListView1.Columns.Add("Price", 70)
  12.         ListView1.Columns.Add("Quantity", 70)
  13.  
  14.         'Add items in the listview
  15.         Dim arr(3) As String
  16.         Dim itm As ListViewItem
  17.  
  18.         'Add first item
  19.         arr(0) = "product_1"
  20.         arr(1) = "100"
  21.         arr(2) = "10"
  22.         itm = New ListViewItem(arr)
  23.         ListView1.Items.Add(itm)
  24.  
  25.         'Add second item
  26.         arr(0) = "product_2"
  27.         arr(1) = "200"
  28.         arr(2) = "20"
  29.         itm = New ListViewItem(arr)
  30.         ListView1.Items.Add(itm)
  31.  
  32.     End Sub
  33.  
  34.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  35.  
  36.         Dim productName As String
  37.         Dim price As String
  38.         Dim quantity As String
  39.  
  40.         productName = ListView1.SelectedItems.Item(0).SubItems(0).Text
  41.         price = ListView1.SelectedItems.Item(0).SubItems(1).Text
  42.         quantity = ListView1.SelectedItems.Item(0).SubItems(2).Text
  43.  
  44.         MsgBox(productName & " , " & price & " , " & quantity)
  45.  
  46.     End Sub
  47. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement