Solved

LsitView Runtime Population

Posted on 2011-03-22
1
210 Views
Last Modified: 2012-05-11
I want to try and populate a list view of 5 columns and 15 rows. When I try and add values to my channelValue string. When I add a value   ChannelValue(0) = "11" how can I move to the next row?
Private Sub frmChannelUpdate_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       

        LV_Channels.View = System.Windows.Forms.View.Details

        ' Adding ListView Columns
        LV_Channels.Columns.Add("RF Channel", 100, HorizontalAlignment.Left)
        LV_Channels.Columns.Add("Min Frequency", 100, HorizontalAlignment.Left)
        LV_Channels.Columns.Add("Middle Frequency", 100, HorizontalAlignment.Left)
        LV_Channels.Columns.Add("Max Frequency", 100, HorizontalAlignment.Left)
        LV_Channels.Columns.Add("Description", 170, HorizontalAlignment.Left)

        Dim ChannelValue(15) As String
        Dim itm As ListViewItem
        ChannelValue(0) = "11"

        itm = New ListViewItem(ChannelValue)
        LV_Channels.Items.Add(itm)


    End Sub

Open in new window

0
Comment
Question by:cmdolcet
1 Comment
 
LVL 53

Accepted Solution

by:
Dhaest earned 125 total points
ID: 35189604
I would use a sub-method which will add the items to your grid (to maintain the code easier).
Example below ....
Private Sub frmChannelUpdate_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       

        LV_Channels.View = System.Windows.Forms.View.Details

        ' Adding ListView Columns
        LV_Channels.Columns.Add("RF Channel", 100, HorizontalAlignment.Left)
        LV_Channels.Columns.Add("Min Frequency", 100, HorizontalAlignment.Left)
        LV_Channels.Columns.Add("Middle Frequency", 100, HorizontalAlignment.Left)
        LV_Channels.Columns.Add("Max Frequency", 100, HorizontalAlignment.Left)
        LV_Channels.Columns.Add("Description", 170, HorizontalAlignment.Left)

' Add the first row
        AddItem "11","12","13","14","15"
' Add the second row
        AddItem "21","22","23","24","25"
...



    End Sub

private sub AddItem (byval RFChannel as string, byval MinFrequency as string, byval MiddleFrequency
 as string, byval MaxFrequency, byval Description as string)
        Dim ChannelValue(5) As String
        Dim itm As ListViewItem
        ChannelValue(0) = RFChannel 
        ChannelValue(1) = MinFrequency 
        ChannelValue(2) = MiddleFrequency
        ChannelValue(3) = MaxFrequency
        ChannelValue(4) = Description 

        itm = New ListViewItem(ChannelValue)
        LV_Channels.Items.Add(itm)
end sub

Open in new window

0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now