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

  • Home
  • SEARCH
  • 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 905289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:11:33+00:00 2026-05-15T16:11:33+00:00

Been a while and I’ve volunteered to teach myself Windows programming at my company.

  • 0

Been a while and I’ve volunteered to teach myself Windows programming at my company. Started writing vbs scripts and suddenly realized how incredibly useful this programming thing is 😉

Anyway, I’m a total newbie at C# AND Visual Studio, I kind of get how it works, you drag and drop interface pieces in the design side then wire them together in the back/program side.

I’m trying to write a program that will (ultimately) read in a (very specific kind of) csv file and give the user a friendlier way to edit and sort through it than Excel. Should be simple stuff, and I’m excited about it.

I started this morning and, with the help of the internet, got as far as reading in and parsing the CSV (which is actually a TSV, since they use tabs not commas but hey).

I’ve been trying to figure out the best way to display the information, and, for now at least, I’m using a DataGridView. But the data isn’t displaying. Instead, I’m seeing a long grid of values with column headers of Length, LongLength, Rank, SyncRoot, IsReadOnly, IsFixedSize, and IsSynchronized.

I don’t know what any of these mean or where they come from, and unfortunately I don’t know how change them either. Maybe somebody can help?

Here is my code:

using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace readInCSV
{
public partial class readInCSV : Form
{
public readInCSV()
{
InitializeComponent();
}

    public List<string[]> parseCSV(string path)
    {
        List<string[]> parsedData = new List<string[]>();
        try
        {
            using (StreamReader readfile = new StreamReader(path))
            {
                string line;
                string[] row;
                while ((line = readfile.ReadLine()) != null)
                {
                    row = line.Split('\t');
                    parsedData.Add(row);
                }
            }
        }
        catch (Exception e)
        {
            MessageBox.Show(e.Message);
        }

        return parsedData;
    }

    //PRIVATE METHODS FROM HERE ON DOWN

    private void btnLoadIn_Click(object sender, EventArgs e)
    {
        int size = -1;
        DialogResult csvResult = openCSVDialog.ShowDialog();

        if (csvResult == DialogResult.OK)
        {
            string file = openCSVDialog.FileName;
            try
            {
                string text = File.ReadAllText(file);
                size = text.Length;
            }
            catch (IOException)
            {
            }
        }
        dgView.Dock = DockStyle.Top;
        dgView.EditMode = DataGridViewEditMode.EditOnEnter;
        dgView.AutoGenerateColumns = true;
        dgView.DataSource = parseCSV(openCSVDialog.FileName);
    }

    private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
    {

    }

    private void openCSVDialog_FileOk(object sender, CancelEventArgs e)
    {

    }
}

}

Thanks in advance!

  • 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-05-15T16:11:33+00:00Added an answer on May 15, 2026 at 4:11 pm

    What’s happening here is that the DataGridView is trying to display all the information for each of the string arrays in your parsedData List.

    When you set a DataGridView’s DataSource as a List of objects, it attempts to interpret each of the objects as a row to display. parsedData is a List of string array objects, so the grid is showing you all the displayable properties for an array object.

    What we can do is parse each TSV row into a custom class (call it TsvRow) which has all the relevant data exposed. The TsvRow objects are then placed in a List and passed to the DataGridView. An example of this approach is explained in this article.

    For example:

    public class TsvRow
    {
        // Properties to hold column data
        public string Column1 { get; set; }
        public string Column2 { get; set; }
    }
    

    …

    public List<TsvRow> parseCSV(string path)
    {
        List<TsvRow> parsedData = new List<TsvRow>();
    
        try
        {
            using (StreamReader readfile = new StreamReader(path))
            {
                string line;
                string[] row;
    
                while ((line = readfile.ReadLine()) != null)
                {
                    row = line.Split('\t');
    
                    // Here we assume we know the order of the columns in the TSV
                    // And we populate the object
                    TsvRow tsvRow = new TsvRow();
                    tsvRow.Column1 = row[0];
                    tsvRow.Column2 = row[1];
    
                    parsedData.Add(myObject);
                }
            }
        }
        catch (Exception e)
        {
            MessageBox.Show(e.Message);
        }
    
        return parsedData;
    }
    

    Since all your column data is exposed as properties (i.e. “Column1” and “Column2”), they should be reflected in the DataGridView automatically.

    Hope that helps! Please let me know if this needs clarification.

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

Sidebar

Related Questions

i've been programming a while in D (http://www.digitalmars.com/d/) now. I prefer it to Java
It's been quite a while since I last used D Programming Language , and
Been a while since I've dealt with ASP.NET and this is the first time
It's been a while since I've had to do any HTML-like code in Vim
It's been a while since I've programmed a GUI program, so this may end
It's been a while since I last coded arm assembler and I'm a little
It's been a while since I was in college and knew how to calculate
It's been a while now since Microsoft stopped supporting Embedded Visual C++ 4.0 (eVC
It's been a while since I used GTK+, and the last time I did
It's been a while since I programmed in C++, and after coming from python,

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.