Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7833301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:39:03+00:00 2026-06-02T12:39:03+00:00

How to traverse the list view column so that we can check whether item

  • 0

How to traverse the list view column so that we can check whether item in the list view column already exist or not and if it exist then change the item .

for example i have a list view with (quantity and item) and i want to check if the newly added item already exist in the list view then only change the quantity to quantity ++ rather then adding new item.

string[] saLvwItem = new string[4];
saLvwItem[0] = a.ToString();
saLvwItem[1] = r["ItemNumber"].ToString();
saLvwItem[2] = r["ItemName"].ToString();
saLvwItem[3] = r["Price"].ToString();

ListViewItem lvi = new ListViewItem(saLvwItem);
listView1.Items.Add(lvi);

all the values are coming from database.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T12:39:05+00:00Added an answer on June 2, 2026 at 12:39 pm

    If you are trying to match on ItemName (columnIndex=2) and increase the ItemNumber (columnIndex=1), then this may work:

        private void InsertOrUpdateItem(ListView listView, string[] saLvwItem)
        {
            if (saLvwItem == null || saLvwItem.Length < 4)
            {
                return;
            }
    
            bool bFound = false;
            foreach (ListViewItem lvi in listView.Items)
            {
                if (lvi.SubItems[2].Text == saLvwItem[2])
                {
                    // item already in list
                    // increase the ItemNumber
                    lvi.SubItems[1].Text = (Convert.ToInt32(lvi.SubItems[1].Text) + Convert.ToInt32(saLvwItem[1])).ToString();
                    bFound = true;
                    break;
                }                
            }
    
            if (!bFound)
            {
                // item not found
                // create new item
                ListViewItem newItem = new ListViewItem(saLvwItem);
                listView.Items.Add(newItem);
            }
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can traverse the list of notifications by using FQL. Great. Now, how do
I have a custom control that is derived from ListView . This list view
How do I traverse a list in reverse order in Python? So I can
i am trying to traverse a given directory and create a list of files
I have a List of tuples, and I'd like to traverse and get the
Trying to do it through a loop that traverses through the list. In the
I would like to traverse the HASH but one by one. Not in Random
How can I traverse through this set of data? String[] from = new String[]{AppSQLite.KEY_NAME,AppSQLite.KEY_ICON};
I am not sure why List as a general data structure should have binary
What is the best way to test whether a list contains a given value

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.