Solved

How to add data to listview columns

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

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.

752 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