开发者

Inserting rows into DataGridView using C#

I am currentl开发者_如何学Goy developing a desktop application.

I have a DataTable filled up. How do I insert those data to the DataGridView?


try this,

//the DataGridView
DataGridView myDataGriView = new DataGridView();

//Declare BindingSource to sync DataGridView and data table
BindingSource myBindingSource = new BindingSource();

//set the DataSource property of your BindingSource 
myBindingSource.DataSource = myDataTable;

//set the DataSource property of your DataGridView 
myDataGridView.DataSource = myBindingSource;

Hope it helped,

If you want more information of populating your dataTable with data from a database you can check this tutorial.


DataGridView.DataSource = yourDataTable;

If it is by any chance an ASP .NET Appication, don't forget to add

DataGridView.DataBind();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜