Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to add data to listview columns

Posted on 2011-03-03
2
Medium Priority
?
688 Views
Last Modified: 2012-05-11
I have a listview that I created 2 columns with.  I use code to update the listview with items the user has selected.  Here is the code, however I never see anything in the second column mTag is a variable I need in the second column.  Also can you a column to be multiline line item, say column 1 has the description and it takes more the 1 line to write it.

thanks

mInspectionCost = mInspectionCost + CDbl(mTag)
        Dim myGroup As String = tabInspection.SelectedTab.Text
        Dim myObj As New ListViewItem
        'mListArray.Add(New listitem(mgroup, mTag))
        myObj.Text = myGroup & Space(2) & mText
        myObj.SubItems.Add(mTag)

        ListBox1.Items.Add(myGroup & Space(2) & mText & "..." & mTag)
        'ListView1.Items.Add(myGroup & Space(2) & mText & "..." & mTag)
        ListView1.Items.Add(myObj)
        lblTotalCharges.Text = CDbl(lblTotalCharges.Text) + (CDbl(mTag) * CDbl(mQty))
        If mResident = True Then
            lblResiCharges.Text = CDbl(lblResiCharges.Text) + (CDbl(mTag) * CDbl(mQty))
        Else
        End If
        lblTotalCharges.Text = FormatCurrency(lblTotalCharges.Text, 2)
        lblResiCharges.Text = FormatCurrency(lblResiCharges.Text, 2)

Open in new window

0
Comment
Question by:mgmhicks
  • 2
2 Comments
 
LVL 3

Accepted Solution

by:
pasolo earned 2000 total points
ID: 35030531
The first column is a ListViewItem, the second and others are subitems of the firts column.
Then, something like this is expected to work;

Dim LVI as ListViewItem = myGroup & Space(2) & mText & "..." & mTag)
LVI.Text = myGroup & Space(2) & mText
LVI.SubItems.Add(mTag)

This mean that you can not add subitems before adding the item :)
0
 
LVL 3

Expert Comment

by:pasolo
ID: 35030548
OOps

Dim LVI as ListViewItem =ListBox1.Items.Add(myGroup & Space(2) & mText & "..." & mTag)
LVI.Text = myGroup & Space(2) & mText
LVI.SubItems.Add(mTag)

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
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…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

879 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