如何在数据网格视图中保留值? [英] How could I retain the values in a data grid view?

查看:70
本文介绍了如何在数据网格视图中保留值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的设计中,有一个包含两个按钮的主窗体。在第一个按钮上单击,form1被加载,在第二个窗体上。

我点击第一个按钮查看form1,然后我点击了button2加载包含数据网格视图的form2,内容为电子邮件地址。



我的问题是,



如果在打开form1之后再次重新加载form2时,如何在数据网格视图中保留这些值。



请帮忙。

In my design,There is a main form which contains two buttons.On first button click,form1 is loaded and on second form2.
I clicked first button to view form1 ,then i clicked button2 to load form2 which contains a data grid view with contents as email adresses.

My problem is,

How to retain these values in data grid view ,when reloading the form2 again ,after form1 is opened.

Please help.

推荐答案

这里的解决方案是否可能这么简单:永远关闭第二个表格;当你想隐藏它时,只需使用:



secondForm.Hide();

//或

secondForm.Visible = false;



当然,使用:



secondForm.Show() ;

//或

secondForm.Visible = true;



再次显示表格。 />


如果你这样做,无论状态控件,以及第二张表格中DataGridView中的相关数据都将保持不变。



当然,当你关闭正在运行的应用程序时,此时你需要保存/保存你的数据(序列化)。
Is it possible the solution here is this simple: never close the second Form; when you want it hidden, just use:

secondForm.Hide();
// or
secondForm.Visible = false;

And, of course, use:

secondForm.Show();
// or
secondForm.Visible = true;

To show the Form again.

If you do this, whatever "state" the Controls, and associated data in the DataGridView, on the second Form are will be unchanged.

Of course, when you close your running Application, at that point you will need to persist/save your data (serialize).


这篇关于如何在数据网格视图中保留值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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