简体   繁体   English

如何在本地存储表中的数据并将其呈现在C#中

[英]How to store data in a table locally and present it in C#

I want to setup a table that can: 我想设置一个表格,可以:

  1. Save the data on the user's machine 将数据保存在用户的计算机上
  2. Reference & present the data in the GUI 在GUI中引用和显示数据
  3. Capable of adding rows dynamically during runtime 能够在运行时动态添加行

What's the best way to go about this? 最好的方法是什么?

DataGridView or TableLayoutPanel or...? DataGridView或TableLayoutPanel还是......? I'm having trouble with SQL server CE, as I was going to connect it with the DataGridView, but I'm very new to this kind of work, and wondered if it was even necessary to use SQL. 我在使用SQL Server CE时遇到了麻烦,因为我要将它与DataGridView连接起来,但我对这种工作很新,并且想知道是否有必要使用SQL。

SQL CE should work OK, but no: you don't have to use SQL. SQL CE应该工作正常,但没有:你没有使用SQL。 You could just populate a DataSet and save/load that to a file on disk. 您可以只填充DataSet并将其保存/加载到磁盘上的文件中。 Or you could use any other serializable object tree and a serializer such as XmlSerializer etc. All of these should work fine with standard bindings like DataGridView . 或者您可以使用任何其他可序列化的对象树和序列化程序,如XmlSerializer等。所有这些都应该可以使用标准绑定,如DataGridView Note, though, that databases get you more granular control over the data. 但请注意,数据库可以让您更精细地控制数据。 It all depends on whether that is valuable, or if a single flat file will suffice. 这一切都取决于它是否有价值,或者单个平面文件是否足够。

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

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