在运行时创建并绑定Gridview

时间:2014-07-31 06:47:51

标签: c# winforms datagridview

我有WINFORM,我想在运行时设置和绑定DataGridView的dataSource。

我有相同的代码,但它似乎不起作用

DataTable dtAppointmentForPrint = new DataTable();
GetAppointments(null, out dtAppointmentForPrint);

DataGridView temp = new DataGridView();
temp.AutoGenerateColumns = true;
temp.DataSource = dtAppointmentForPrint;
temp.Refresh();

当我在那里探索gridview的数据源时,列数为零。

0 个答案:

没有答案