Solved

LsitView Runtime Population

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

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…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

691 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