Solved

LsitView Runtime Population

Posted on 2011-03-22
1
221 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

820 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