?
Solved

LsitView Runtime Population

Posted on 2011-03-22
1
Medium Priority
?
225 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 53

Accepted Solution

by:
Dhaest earned 500 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

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.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month15 days, 6 hours left to enroll

741 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