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 8817149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:46:41+00:00 2026-06-14T04:46:41+00:00

I have a ListView with 2 columns. For example’s sake, we’ll say it looks

  • 0

I have a ListView with 2 columns. For example’s sake, we’ll say it looks like this:

ColA    | ColB  
-----------------
001     |  
002     |  
003     |  
004     |  
005     |  

I have a text file that contains the following lines:

001  
002  
004  
005  
008  

I’m trying to read through the file line by line, and if the number matches a number in ColumnA, I want to add it to ColumnB. That works fine (see my example below). However, I’d also like to add any non-matches as a new ListViewItem. I can’t figure that part out. Here’s what I have so far:

foreach (string textfileitem in TheTextFile)
{
    foreach (ListViewItem item in ListView1.Items)
    {
        var existingitem = item.SubItems[0];

        if (existingitem.Text == textfileitem)
        {
            item.SubItems[1].Text = textfileitem;
        }
    }
}

I’m not sure how to handle any non-matches and add them to the ListView. the end result would look like this:

ColumnA | ColumnB
----------------- 
001     | 001
002     | 002
003     | 
004     | 004
005     | 005
-       | 008

As always, your help is appreciated!

  • 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-14T04:46:42+00:00Added an answer on June 14, 2026 at 4:46 am

    Run through your columnA, create a dictionary of <String,YourDataSourceItem>. Run through your file – test match using TryGetValue. If found, set columnB. If not, create a new item.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ListView that looks like this: The combo box is bound to
I have a ListView which has bound data, and two additional bindings like this:
I have ListView that uses a GridView to display several columns of data. Two
I have a ListView with a GridView with 3 columns. I want last column
I have a listview in c# with three columns and the view is details.
Background: I have a ListView / GridView with several columns. In some situations, only
I have a ListView control set up in details mode with 5 columns. It
I have a ListView with a CheckBox as one of the columns, bound to
Is it possible to have a single listview with 2 or more columns, operable
I have 2 Android Databases in my app. For the sake of an example,

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.