单击一个表单更新另一表单上的datagridview [英] click on one form updates datagridview on other form

查看:84
本文介绍了单击一个表单更新另一表单上的datagridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在.Net 2.0和Visual Studio 2005中使用C#Windows For Application.我有2种形式.

1.具有datagridview的MDI表单.
2.用于输入值的Windows表单.

Windows数据输入表单上有2个按钮,它们的功能:
1.输入"按钮:单击后,数据应保存在数据库中.数据输入表单应消失.必须使用新条目更新MDI表单上的datagridview.

2.输入另一个"按钮:单击后,数据应保存在数据库中.必须使用新条目更新MDI表单上的datagridview.数据输入表单应准备好再次输入.

当我单击输入另一个"按钮时,除非手动重新启动表单,否则MDI表单上的datagridview不会显示更新的数据行.

另一件事是我很清楚实现逻辑,但是我无法将其转换为C#代码.
有什么解决方案?

在此先感谢....

I am using C# Windows For Application in .Net 2.0 and Visual Studio 2005. I have 2 forms.

1. MDI form which has the datagridview.
2. Windows form used for entering the values.

There are 2 buttons on windows data entry form Their functionalities:
1. ''Enter'' button: when clicked the data should be saved in the database. the data entry form should disappear. the datagridview on MDI form must be updated with the new entry.

2. ''Enter Another'' button: when clicked the data should be saved in the database. the datagridview on MDI form must be updated with the new entry. the data entry form should be ready for another entry.

When i clicked on ''Enter Another'' button, the datagridview on MDI form does not show updated data row unless I manually restart the form.

Another thing is that the implementation logic is clear to me but I am unable to convert it into C# code.
What could be solution?

Thanks in advance....

推荐答案

我认为您应该在两个表单之间共享相同的数据源对象.可以将同一数据绑定到多个控件上.

如果将dataGridView绑定到数据源对象,并且您手动将数据更新到该对象中,则gridView将自动更新其内容.
I think that you should share the same datasource object between your two forms. It is possible to bind the same data on more than one control.

If a dataGridView is binded to a datasource object and you manualy update data into the object, then the gridView will update it''s content automatically.


这篇关于单击一个表单更新另一表单上的datagridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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