如何将DataGridview数据保存到数据表(在Windows窗体中) [英] How to save DataGridview data to datatable (in Windows Form)

查看:106
本文介绍了如何将DataGridview数据保存到数据表(在Windows窗体中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好程序员。

我正在使用Windows窗体中的项目并且有一个问题。我正在将数据从excel导入到没有数据库的Datagridview中。我想保存这些数据,以便下次Form启动时,在dgv中显示包含以前Form中数据的新数据。我可以不使用数据库吗?有没有办法在datatable或dataset中保存数据?

Hello programmers.
I'm working on a Project in Windows Forms and have a Question. I'm importing data from excel into Datagridview without database. I want to save this data so that for the next time when Form starts, display in dgv new datas with datas from previously Form. Can I do this without using database ? Is there any way to save datas in datatable or dataset ?

推荐答案

您可以使用系统直接从每个单元格中获取每一个数据.Windows.Forms.DataGridViewCell.Value 并使用适当的SQL 语句更新您的数据库。但最广泛使用的方法是基于数据绑定



请参阅:

如何:将数据绑定到Windows窗体DataGridView控件 [ ^ ],
在Windows窗体DataGridView控件中显示数据 [ ^ ],

绑定类(System.Windows.Forms) [ ^ ],

http://www.bluevisionsoftware.com/website/books/0972317929/ch06.pdf [ ^ ]。



这些CodeProject文章也可以很有用:

详细的数据绑定教程 [ ^ ],

.NET窗体中的数据绑定概念 [ ^ ]。



-SA
You can directly get each and every piece of data from each cell using System.Windows.Forms.DataGridViewCell.Value and update your database using appropriate SQL statements. But most widely used approach is based on data binding.

Please see:
How to: Bind Data to the Windows Forms DataGridView Control[^],
Displaying Data in the Windows Forms DataGridView Control[^],
Binding Class (System.Windows.Forms)[^],
http://www.bluevisionsoftware.com/website/books/0972317929/ch06.pdf[^].

These CodeProject articles can also be useful:
A Detailed Data Binding Tutorial[^],
Data binding concepts in .NET windows forms[^].

—SA


这篇关于如何将DataGridview数据保存到数据表(在Windows窗体中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆