刷新主窗体中可用的数据网格视图 [英] Refreshing a datagridview available in main form

查看:65
本文介绍了刷新主窗体中可用的数据网格视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Windows窗体应用程序中,有两种形式即: MainForm(父表单)和ProductionDetails(子表单)。每当我运行应用程序时,MainForm首先打开。在MainForm中,有一个dataGridview1用于显示DB中Production表的生产数据,一个button1控件用于打开MainForm上面的ProductionDetails。

现在,我的查询就是每当我插入一个新行时在DB的Production表中,MainForm中可用的dataGridview1应该在同一时间刷新。请帮我解决这个问题。

In my Windows Form Application, there are two forms viz; MainForm(Parent Form) and ProductionDetails(Child Form) . Whenever I run the application the MainForm opens first. In the MainForm, there is a dataGridview1 is used for displaying Production data from Production table in DB and a button1 control to open ProductionDetails above MainForm.
Now, my query is that, whenever I insert a new row in Production table in DB, the dataGridview1 available in MainForm should be refreshed in the same time. Please help me in solving this problem.

推荐答案





我会问你有什么事吗到目前为止尝试过我想你应该在问问题之前尝试一下,然后问你是否有任何困难。请记住,这是一个面临问题的社区,每个人都会受益于他们在开发过程中遇到的各种问题。



无论如何,就你的问题而言,在父表单中有一个静态方法,只要你更新任何记录就会从子表单中调用它。

如果您希望它不断更新DataGridView(取决于您的情况),请使用计时器和后台工作程序来调用数据库,然后更新DataGridView。



希望这有帮助。
Hi,

I would ask you what have you tried so far. I think you should probably try something before you ask the question and then ask if you have any difficulties. Please remember that this is a community where issues faced are resolved and everyone gets benefited by different kinds of issues they face while developing something.

Anyway, as far as your question goes, have a static method in the parent form which gets called from the child form whenever you update any records.
If you want it to constantly update the DataGridView (depending upon your situation), use a timer along with a background worker to call the database and then update the DataGridView.

Hope this helps.


这篇关于刷新主窗体中可用的数据网格视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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