CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2010
    Posts
    56

    Duplicate Columns

    I am writing a portion of my program that reads in a CSV file, then a seperate of values occur, and this data is added to a row of a data table. The problem is when I assign my data table to a data source its duplicating my column headers. I would expect it to properly load my data into my existing data grid.

    Here is a screen shot of what is happening. Left is in VS right is the program running.

    http://i.imgur.com/kTdY3.jpg

    Code:
            private void LoadDataGridView()
            {
                DataTable dt = new DataTable();
    
                //Set the data table to have the same columns as our gridview
                foreach (DataGridViewColumn col in jobDataGridView.Columns)
                {
                    dt.Columns.Add(col.HeaderText, col.CellType);
                }
    
                //Set the data table to have our initial load
                List<string> jobList = jobUpdate.InitialLoad();
                foreach (string x in jobList)
                {
                    string[] split = x.Split(',');
                    dt.Rows.Add();
                }
    
                jobDataGridView.DataSource = dt;
            }

  2. #2
    Join Date
    Jun 2010
    Posts
    56

    Re: Duplicate Columns

    The second I posted it I thought of a solution. I don't need to worry about creating a data table, I can go straight to the data grid for what I am doing which resolves my issue.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured