I am working with different datasources which is having different columns. For example DataTable1 has A,B and C Column. and DataSource2 has X,Y,Z Columns.
In my windows form application I am allowing user to browse a certain Excel file with Format1 (A,B,C) and Format2 (X,Y,Z). when I load first datasource1 in grid view it shows columns A,B,C and it's data from excel. But when I load Format2. Datagridview retains the format from Datasource1 and shows (A,B,C,X,Y,Z) columns.
Please note that I have common datagridview for both data source. Also, I have tried following
DataTable.Clear();
DataTable.Columns.Remove("");
AutoGeneratedColumns=False;
How do I make sure that datagridview shows only the current Datasource related columns while user is selecting the excel.
DataSource1 - Format 1 - A,B,C DataSource2 - Format 2 - X,Y,Z
AutoGeneratedColumns=False
?