How to make a DataTable from DataGridView without any Datasource?

前端 未结 3 837
野性不改
野性不改 2020-12-03 14:57

I want to get a DataTable from DataGridView of the Grid values.

In other words DataTable same as DataGridView Values

3条回答
  •  天涯浪人
    2020-12-03 15:05

    You can cast the DataSource object from the DataGridView to a DataTable

    DataTable dt = new DataTable();
    dt = (DataTable)dataGridView1.DataSource;
    

提交回复
热议问题