-
April 24th, 2012, 05:44 PM
#1
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;
}
-
April 24th, 2012, 06:07 PM
#2
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|