简体   繁体   English

如何在数据集表/列中存储列表或集合? (VB.NET)

[英]How to store a List or Collection in a dataset table/column? (VB.NET)

I have a dataset table with various columns that are created during form load. 我有一个数据集表,其中包含在表单加载期间创建的各种列。 These columns are currently either system.double or system.string types. 这些列当前为system.double或system.string类型。 And it is displayed in a datagridview. 它显示在datagridview中。 This works fine. 这很好。

But I need another column that can store a "list" or some collection in the data table. 但是我需要另一个可以在数据表中存储“列表”或某些集合的列。 A list of strings would do but a custom class would be better. 可以使用字符串列表,但是自定义类会更好。

How is this usually done? 通常如何做?

I have spent literally weeks googling this and I dont know where to start. 我花了数周的时间在谷歌上搜索,但我不知道从哪里开始。 The more I have looked the more confused I have ended up. 我越看越困惑。 I end up with more questions than answers, like how is it displayed in the datagridview? 我最终提出的问题多于答案,例如它如何显示在datagridview中? I read about a combo box? 我读过一个组合框?

I hope someone can give me some pointers in how to get this achieved. 我希望有人能给我一些指导,以实现这一目标。 I've not posted any code as I think its more the theory of this I need help with. 我还没有发布任何代码,因为我认为这更多的是我需要帮助的理论。

What you are asking for has does have multiple concerns for most programmers. 对于大多数程序员来说,您所要求的确实有很多问题。 The storage of data (#1) and the displaying of said data to the user (#2) 数据的存储(#1)以及向用户显示数据(#2)

For #1 I recommend the .net entity framework. 对于#1,我建议使用.net实体框架。 It gives support for storing, querying and updating classes for use in the database. 它支持存储,查询和更新要在数据库中使用的类。 Through most tutorials that I have found it is possible to model the structure of the database tables and their relations and then build a database around that model OR to use an existing database and create entities (entity framework's class objects) around the existing structures and relationships. 通过我发现的大多数教程,可以对数据库表及其关系的模型进行建模,然后围绕该模型构建数据库,或者使用现有数据库并围绕现有结构和关系创建实体(实体框架的类对象) 。

Here is a link to a very good beginner tutorial that I have used before: CodeProject Entity Framework Tutorial for Absolute Beginners 这是我以前使用过的非常好的初学者教程的链接: 绝对初学者的CodeProject实体框架教程

For #2 I can recommend the Windows Presentation Foundation. 对于#2,我可以推荐Windows Presentation Foundation。 It has lots of bells and whistles to make using a data source and displaying the relevant dependent data very easily through its unique method of data binding. 它通过其独特的数据绑定方法可以轻松地使用数据源并轻松显示相关的依存数据,从而产生了许多麻烦。 From the tutorials I have used on PluralSight it can be as easy as dragging and dropping from an imported data source like the entity framework database. 从我在PluralSight上使用的教程中, 就像从导入的数据源(如实体框架数据库)中拖放一样容易。 Alternatively, one can just handle selected row changes for one data grid and then show the dependent data in another data grid. 或者,可以只处理一个数据网格的选定行更改,然后在另一数据网格中显示相关数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM