- void loadData()
- {
- dt = new DataTable();
- dt.Columns.Add("Country", typeof(string));//dont want to add these columns here want to use columns from datagrid
- dt.Columns.Add("Sales", typeof(int));//dont want to add these columns here want to use columns from datagrid
- dt.Rows.Add(new object[] { "Argentina", 2000 });
- dt.Rows.Add(new object[] { "Belgium", 4500 });
- dataGridView1.DataSource = dt;
- }
Use datagridview columns added from the designer on data table
I need to use BindingSource class to filter data and i dont know how else i can do it so that I have columns added from the designer and am able to filter datagrid. https://stackoverflow.com/questions/63245000/filter-datagrid-view-from-data-populated-from-entity-in-c-sharp is the post that I had previously posted to get help on how to filter datagridview but the solutions seems is have to bind data using datasource. I need to maintain the style and format applied to the datagridview columns on the designer
I have created a datagridview in designer view and added columns to it. My question is how I can access these columns from my DataTable object instead of again manually adding columns to the Datatable again(Re use columns added from datagridview on Datatable). This is what have done so far

Denis Morgan84 reputationPosted Aug 14, 2020, 1:21 AM EDT
Laxmidhar SahooRank #383 · 6.6K reputationPosted Aug 14, 2020, 2:30 AM EDT
Denis Morgan84 reputationPosted Aug 14, 2020, 2:50 AM EDT
Navaneeth KrishnanRank #1,172 · 1.5K reputationPosted Aug 14, 2020, 7:22 AM EDT
Laxmidhar SahooRank #383 · 6.6K reputationPosted Aug 14, 2020, 11:00 PM EDT
Laxmidhar SahooRank #383 · 6.6K reputationPosted Aug 14, 2020, 12:53 AM EDT