Hai All,
i am having a list view with some row values(say 10) that i populated from the DB . what i want to know is how i can get one row and and its subitems at a time one after the other and its details(items) so that based on each row wise values(item) i need to make some other manipulations on the data.
Please help me on this


JThom

Imports System
Imports System.Windows.Forms
Imports System.Drawing
Public Class Form4
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()
        ListView.Dock = DockStyle.Fill
        PopulateListView()
        Me.Controls.Add(ListView)
        Me.ClientSize = New Size(400, 200)
        'Add any initialization after the InitializeComponent() call

    End Sub

    .....
	
#End Region
   
    Private Sub PopulateListView()
        ' Set the view to show details.
        ListView.View = View.Details

        ' Add columns
        ListView.Columns.Add("Author", -2, HorizontalAlignment.Center)
        ListView.Columns.Add("Title", -2, HorizontalAlignment.Left)
        ListView.Columns.Add("Price", -2, HorizontalAlignment.Left)

        ' Add items
        Dim item1 As New ListViewItem("Steve Martin")
        item1.SubItems.Add("Programming .NET")
        item1.SubItems.Add("39.95")

        Dim item2 As New ListViewItem("Irene Suzuki")
        item2.SubItems.Add("VB.NET Core Studies")
        item2.SubItems.Add("69.95")

        Dim item3 As New ListViewItem("Ricky Ericsson")
        item3.SubItems.Add("Passing Your .NET Exams")
        item3.SubItems.Add("19.95")

        ' Add the items to the ListView.
        ListView.Items.AddRange(New ListViewItem() {item1, item2, item3})
    End Sub


    Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim form As New ListView
        form.Show()
    End Sub


    Private Sub ListView_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView.SelectedIndexChanged
        On Error Resume Next
        MsgBox(ListView.SelectedItems(0).Text + ", " + ListView.SelectedItems(0).SubItems(1).Text + ", " + ListView.SelectedItems(0).SubItems(2).Text)
    End Sub
End Class
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.