Solved

How to add data to listview columns

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Text in tooltip bound field bridview 3 30
Handling arrays 14 35
Need help with a query 6 55
Recommendation vb6 to vb.net or others 14 44
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now