如何以MDI形式从一个子屏幕向网格视图输入数据. [英] How to enter data from one child screen to grid view in MDI form.

查看:160
本文介绍了如何以MDI形式从一个子屏幕向网格视图输入数据.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I have a MDI window with a datagridview control which is used to display a list of records in a database table(s). If the user wants to add a new record, they click "new" and a popup(Child) window displays. The popup window accepts data from the user (name, number, date, etc) and is then submitted.when the users clicks an ok button. At this point I want to update the database with the new record, close the popup(child) window, and then refresh the parent window datagridview so that it reflects the newly added record that was created using the popup window.

The child form will appear on clicking the menue.

while child window closing event how to handle refresh MDI Parent DataGridview?


Regards,
Sarthak Mishra

推荐答案

如果它是弹出窗口,那么最简单的方法是使用myPopupForm.ShowDialog
这将阻止"原始表单代码,直到用户关闭弹出窗口.
然后,您可以通过属性使用弹出窗口实例将行添加到DGV:
If it''s a popup window, then the easiest way to do it is to show the window with myPopupForm.ShowDialog
That "blocks" the original form code until the user closes the pop-up.
You can then use the pop-up instance via properties to add a row to the DGV:
MyPopup myPop = new MyPopup();
if (myPop.ShowDialog() == DialogResult.OK)
   {
   string name = myPop.ClientName;
   string mobile = myPop.MobileNumber;
   ...
   myDataGridView.Rows.Add(name, mobile, ...
   }


我将为您提供另一种更实用的建议:避免使用MDI.

这是一个主意:谁曾经需要MDI?为什么要折磨自己并吓users用户?
帮自己一个忙:根本不要使用MDI.没有设计,您可以更轻松地实现设计,并且质量更高.即使Microsoft也不鼓励使用MDI,实际上,Microsoft已将其从WPF中删除,并且几乎不支持它.更重要的是,如果您使用MDI,则会吓跑所有用户.只是不要.请参阅:
http://en.wikipedia.org/wiki/Multiple_document_interface#Disadvantages
如何在WPF中创建MDI父窗口?.

我可以解释该怎么做.请查看我过去的答案:
如何在WPF中创建MDI父窗口?
在WPF中使用MDI窗口的问题
MDIContainer输入错误
如何最大程度地设置子表单,最小化最后一个子表单.

—SA
I''ll give you an alternative, much more practically useful advice: avoid using MDI.

Here is the idea: who needs MDI, ever? Why torturing yourself and scaring off your users?
Do yourself a great favor: do not use MDI at all. You can do much easier to implement design without it, with much better quality. MDI is highly discouraged even by Microsoft, in fact, Microsoft dropped it out of WPF and will hardly support it. More importantly, you will scare off all your users if you use MDI. Just don''t. Please see:
http://en.wikipedia.org/wiki/Multiple_document_interface#Disadvantages,
How to Create MDI Parent Window in WPF?.

I can explain what to do instead. Please see my past answers:
How to Create MDI Parent Window in WPF?,
Question on using MDI windows in WPF,
MDIContainer giving error,
How to set child forms maximized, last childform minimized.

—SA


这篇关于如何以MDI形式从一个子屏幕向网格视图输入数据.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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