DataGridView 创建后不显示行
我正在使用 Visual Studio 10,并且刚刚使用 SQL Server CE 创建了一个数据库。在其中,我创建了一个表 CSLDataTable
并自动创建了一个 CSLDataSet
& CSLDataTableTableAdapter
。
这三个变量是在我的 MainWindow.cs 类中自动创建的:
cSLDataSet
cSLDataTableTableAdapter
cSLDataTableBindingSource
我在中添加了一个 DataGridView
我的表单名为 dataGridView
和数据源 cSLDataTableBindingSource
。
在我的 MainWindow() 中,我尝试添加一行作为测试:
public MainWindow()
{
InitializeComponent();
CSLDataSet.CSLDataTableRow row = cSLDataSet.CSLDataTable.NewCSLDataTableRow();
row.File_ = "file";
row.Artist = "artist11";
row.Album = "album";
row.Save_Structure = "save";
row.Sent = false;
row.Error = true;
row.Release_Format = "release";
row.Bit_Rate = "bitrate..";
row.Year = "year";
row.Physical_Format = "format";
row.Bit_Format = "bitformat";
row.File_Path = "File!!path";
row.Site_Origin = "what";
cSLDataSet.CSLDataTable.Rows.Add(row);
cSLDataSet.AcceptChanges();
cSLDataTableTableAdapter.Fill(cSLDataSet.CSLDataTable);
cSLDataTableTableAdapter.Update(cSLDataSet);
dataGridView.Refresh();
dataGridView.Update();
}
关于我尝试调用的 DataSet 方法,我一直在尝试找到一种与适配器、数据集和数据表交互的“正确”方法,以成功显示行,但无济于事。
我对使用 SQL Server CE 数据库相当陌生,并且阅读了很多 MSDN 网站和文档。我以为我走在正确的道路上,但我没有运气。
DataGridView
正确显示标题,但新行未显示。
I'm using Visual Studio 10 and I just created a Database using SQL Server CE. Within it, I made a table CSLDataTable
and that automatically created a CSLDataSet
& CSLDataTableTableAdapter
.
The three variables were automatically created in my MainWindow.cs class:
cSLDataSet
cSLDataTableTableAdapter
cSLDataTableBindingSource
I have added a DataGridView
in my Form called dataGridView
and datasource cSLDataTableBindingSource
.
In my MainWindow(), I tried adding a row as a test:
public MainWindow()
{
InitializeComponent();
CSLDataSet.CSLDataTableRow row = cSLDataSet.CSLDataTable.NewCSLDataTableRow();
row.File_ = "file";
row.Artist = "artist11";
row.Album = "album";
row.Save_Structure = "save";
row.Sent = false;
row.Error = true;
row.Release_Format = "release";
row.Bit_Rate = "bitrate..";
row.Year = "year";
row.Physical_Format = "format";
row.Bit_Format = "bitformat";
row.File_Path = "File!!path";
row.Site_Origin = "what";
cSLDataSet.CSLDataTable.Rows.Add(row);
cSLDataSet.AcceptChanges();
cSLDataTableTableAdapter.Fill(cSLDataSet.CSLDataTable);
cSLDataTableTableAdapter.Update(cSLDataSet);
dataGridView.Refresh();
dataGridView.Update();
}
In regards to the DataSet methods I tried calling, I had been trying to find a "correct" way to interact with the adapter, dataset, and datatable to successfully show the row, but to no avail.
I'm rather new to using SQL Server CE Database, and read a lot of the MSDN sites & thought I was on the right track, but I've had no luck.
The DataGridView
shows the headers correctly, but that new row does not show up.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通过调用
TableAdapterManager.UpdateAll(DataSet)
方法使其正常工作。http://msdn.microsoft.com/en-us/library/bb384426。 ASPX
I've got it to work by calling the
TableAdapterManager.UpdateAll(DataSet)
method.http://msdn.microsoft.com/en-us/library/bb384426.aspx