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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:00:39+00:00 2026-06-14T17:00:39+00:00

How would I go about about replacing the text of blank items in column

  • 0

How would I go about about replacing the text of blank items in column 5 of my listView with the word “No”?

I tried this but it threw an InvalidArgument=Value of '4' is not valid for 'index'. error:

 foreach (ListViewItem i in listView1.Items)
 {
     if (i.SubItems[4].Text == " ")
     {
         i.SubItems[4].Text = i.SubItems[4].Text.Replace(" ", "No");
     }
 }
  • 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-14T17:00:41+00:00Added an answer on June 14, 2026 at 5:00 pm

    The code provided above will get all items within ListView1.Items and check if the sub-item of index 4 and its property Text is equal to   which may result in the described error if the index exceeds the array limit. You may avoid this by making sure that this item is not Nothing.

    Example

    foreach (ListViewItem i in listView1.Items) //Get all items in listView1.Items
    {
       if (i.SubItems.Count > 3) //Continue if i.SubItems.Count is more than 3 (The array contains i.SubItems[3] which refers to an item within the 4th column (i.SubItems.Count is not an array. Therefore, it'll start with 1 instead of 0))
       {
           if (i.SubItems[3].Text == " ") //Continue if i.SubItems[3].Text is equal to  
           {
                i.SubItems[3].Text = i.SubItems[3].Text.Replace(" ", "No"); //Replace   with No
           }
       }
    }
    

    Notice: Arrays are zero-indexed which means that they start with 0 instead of 1.

    Notice: If you only have 4 columns, i.SubItems.Count would be 4 and not 3 because it’s a normal int considering that all columns are filled.

    Thanks,

    I hope you find this helpful 🙂

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

Sidebar

Related Questions

I would like 'about' to route to 'abouts/1' I tried this: match 'about' =>
How would I go about adding text to a UITextView without replacing the previous
Just a quick question about how you would go about implementing this. I want
I'm really struggling with regex here. Using Java how would I go about replacing
How would I go about replacing Windows Explorer with a third party tool such
Any ideas how I would go about writing a javascript method to insert an
I would like to know how I would go about altering the HTML that
I was wondering how one would go about developing a website from scratch with
I'm wondering how i would go about making the following application: a user signs
Anyone have any idea how I would go about converting a timestamp in milliseconds

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.