fileContent has been taken from the previous code, this contain the content of the file. I cast the Datagrid in the DataTable.
dt.Columns.Count counts the column from the grid and add another column in it.
private DataTable addColumn(string fileContent)
{
DataTable dt = (DataTable)gvData.DataSource;
int iColCount = dt.Columns.Count;
dt.Columns.Add("Column" + (iColCount + 1).ToString());
return dt;
}
now this is the button btnAddColumn_Click which add the columns, will call the method addColumn and will add the column in the existing grid
private void btnAddColumn_Click(object sender, EventArgs e)
{
string fileContent = this.readFile(openFileDialog1.FileName);
DataTable dt = this.addColumn(fileContent);
gvData.DataSource = dt;
}
I hope that will be solve your problem.. please let me know if still you feel any problem....
Thursday, March 11, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment