Ming Man Chan wrote:
> Where is your code?
>
> chanmm
The data is definitely loaded in the data table as I have looped through
this and printed the contents.
Once the function completes it appears that the grid has only loaded one
item, as only the top leftmost cell displays data, however if I select a
different cell, then data appears in new cell but old cell appears blank
code below
any ideas please?
fileData.Data is a List of string[];
public partial class MainForm: Form
{
DataTable tableData = new DataTable();
DataRow newDataRow;
DataColumn newDataColumn;
}
private void PopulateGrid()
{
foreach ( string header in fileData.Data[ 0 ] )
{
if ( !( tableData.Columns.Contains( header ) ) )
{
DataColumn newDataCol =
tableData.Columns.Add(header, typeof(String));
newDataCol.AllowDBNull = true;
newDataCol.Unique = false;
}
else
{
DataColumn newDataCol =
tableData.Columns.Add("Duplicate_" + header, typeof(String));
newDataCol.AllowDBNull = true;
newDataCol.Unique = false;
}
}
for ( int j = 1; j < fileData.Data.Count; ++j )
{
newDataRow = tableData.NewRow();
for ( int i = 0; i < fileData.Data[ j ].Length; ++i )
{
newDataRow[ i ] = fileData.Data[ j ][ i ];
}
tableData.Rows.Add( newDataRow );
}
dataGridViewOriginal.DataSource = tableData;
dataGridViewOriginal.Refresh();
}
|