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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:37:40+00:00 2026-06-05T10:37:40+00:00

Currently this is my code. TextReader reader = new StringReader(richTextBox1.Text); string[] strItems = null;

  • 0

Currently this is my code.

        TextReader reader = new StringReader(richTextBox1.Text);
        string[] strItems = null;
        while (reader.Peek() != -1)
        {
            string nextRow = reader.ReadLine();
            if (!listView1.Items.ContainsKey(nextRow.GetHashCode().ToString()))
            {
                ListViewItem item = new ListViewItem();
                item.Name = nextRow.GetHashCode().ToString();
                strItems = nextRow.Split("-".ToCharArray());
                item.Text = strItems[0].ToString();
                try
                {
                    item.SubItems.Add(strItems[1].ToString());
                }
                catch (Exception)
                {
                }
                try
                {
                    item.SubItems.Add(strItems[2].ToString());
                }
                catch (Exception)
                {
                }
                try
                {
                    item.SubItems.Add(strItems[3].ToString());
                }
                catch (Exception)
                {
                }
                try
                {
                    item.SubItems.Add(strItems[4].ToString());
                }
                catch (Exception)
                {
                }
                listView1.Items.Add(item);
            }
        }

It add’s Items from a textbox to a ListView, but if there is a Blank line in the textbox it also adds a blank item to the listview. I am looking for a way to stop this from happening. All 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-05T10:37:42+00:00Added an answer on June 5, 2026 at 10:37 am

    Add an if to check that:

    if(!string.IsNullOrEmpty(nextRow)) {
       execute the code you need
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There is currently this Prototype code that does a PUT: new Ajax.Request(someUrl, { method:
I currently use this code to find gcd and lcm def gcd(a, b): while
I currently have this code that parses imdbAPI http returns: text = 'unicode: {Title:The
I'm currently using this code: com.google.javascript.jscomp.Compiler.setLoggingLevel(Level.OFF); com.google.javascript.jscomp.Compiler compiler = new com.google.javascript.jscomp.Compiler(); CompilerOptions options =
I currently have this code in my game: Vector2 pixelpos = new Vector2(x, y);
I am currently using this code: <script type=text/javascript> $(document).ready(function() { jQuery(#navmain li).click(function(){ jQuery(this).toggleClass(selected); });
I am currently using this code to put some text on the screen userOutput.text=@;
I currently have this code which reads the first field in a database record
i am currently using this code: <div style=width:200px; height:300px;> <img src=./imgs/Apeiron-Island-Hotel.jpg style=width:200px; height:200px;/> <input
I'm currently using this code, and it does what I want it to $('#about-link').click(function()

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.