DataGridView 创建后不显示行

发布于 2024-09-02 08:18:31 字数 1442 浏览 2 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

诠释孤独 2024-09-09 08:18:32

我通过调用 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文