数据集 - 用于在表单中的表之间切换的菜单
我在 C# 中的数据集方面遇到了一些困难。我知道如何加载数据集和所有内容,并且我可以将表格从数据集拖到表单窗口中,并显示该表格的列等。但是,我想以干净的方式显示表单中的每个表格。有没有一种方法可以创建一个下拉列表,例如,它将显示数据集中的所有表,然后我可以选择我想要的表,然后显示列等?只需要一种方法来在表单中显示表格并在它们之间导航并让它们显示数据。我该怎么做呢?
I'm having a bit of difficulty with datasets in C#. I know how to load datasets and everything, and I can drag a table from the dataset into the form window and it displays the columns etc of that table. However, I would like to display every single table in the form, but in a clean way. Is there a way to create a dropdownlist for example, that will display all the tables in the data set, and then I can select the one I want and then display the columns, etc? Just need a way to display tables in the form and navigate between them and have them display their data. How would I go about doing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您需要创建 DataSet(类型化数据集)的实例(例如 DatabaseDataSet),
然后创建适配器的实例,它是一个自动生成的类。
填充数据表对象并推送到 ds。
使用数据绑定技术显示数据集对象中的数据。
题外话:使用Collections、LINQ和Entity框架。 DataSet 有点过时并且有很多问题。请看一下这篇 MSDN 帖子。
数据集与集合
First of all you need to create an instance of DataSet (typed dataset) (say DatabaseDataSet)
Then create adapter's instance which is an autogenerated class.
Pupulate the datatable object and push into to ds.
Use DataBinding technique to show data from the dataset object.
Off-topic:Use Collections, LINQ and Entity framework. The DataSet is bit outdated and it has many problems. Please take a look at this MSDN post.
DataSets vs. Collections