C#DataGridView绑定到表INOP
尝试在数据网格视图中显示表数据。遵循了许多没有解决方案的博客建议。将代码减少到下面的简单测试案例,但网格视图仍然空白。上一次检查网格视图行= 0。(未再次验证此确切的代码,但仍然空白)。
private void ImportTable(string fileName)
{
DataTable table = new DataTable();
table.Columns.Add("Column 1", typeof(int));
table.Columns.Add("Column 2", typeof(int));
table.Rows.Add(1, 2);
dataGridView1 = new DataGridView();
dataGridView1.AutoGenerateColumns = true;
BindingSource SBind = new BindingSource();
SBind.DataSource = table;
dataGridView1.DataSource = SBind;
dataGridView1.Refresh();
}
Trying to display table data in a data grid view. Have followed many blog suggestions with no resolution. Have reduced the code down to the simple test case below but grid view remains blank. Last check grid view Rows = 0. (not verified again for this exact code but still blank).
private void ImportTable(string fileName)
{
DataTable table = new DataTable();
table.Columns.Add("Column 1", typeof(int));
table.Columns.Add("Column 2", typeof(int));
table.Rows.Add(1, 2);
dataGridView1 = new DataGridView();
dataGridView1.AutoGenerateColumns = true;
BindingSource SBind = new BindingSource();
SBind.DataSource = table;
dataGridView1.DataSource = SBind;
dataGridView1.Refresh();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论