Solved

How to add data to listview columns

Posted on 2011-03-03
2
675 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 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
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 …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

789 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