Solved

How to add data to listview columns

Posted on 2011-03-03
2
676 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
[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
  • 2
2 Comments
 
LVL 3

Accepted Solution

by:
pasolo earned 500 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

756 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