如何在mdi父保存按钮单击事件上保存子表单文本框输入值? [英] how to save child form textbox input value on mdi parent Save Button click event?

查看:69
本文介绍了如何在mdi父保存按钮单击事件上保存子表单文本框输入值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的项目中插入了mdiparent表单。它包含一个带有文本框的子表单(Customer Data Entry)。在父表单中有一个工具条按钮(保存记录)。按下保存时记录按钮我想将客户数据输入表单值(子表单文本框值)保存到数据库中。

解决方案

你将必须在子窗体中创建Save方法,然后单击调用类似

(your-child-form-type)this.MdiChildren(your-child-form-index).Save()

如果你当时有一个表格打开那么这个指数总是0





正确的解决方案会让所有孩子都实现一个界面,这样你就可以添加任何你希望实现该界面的子表单并调用它的保存按钮。



另外,你可以拥有所有子级继承自包含必须在每个子级中实现的Save方法的基本抽象类

I inserted mdiparent form in my project.It contains one child form(Customer Data Entry) with textboxes.In parent form one toolstrip button(Save Record).At the time of pressing the Save Record Button I want to Save the Customer Data Entry form Values(Child form Text Box values) in to Database.

解决方案

You'll have to create Save method in the child form and then on click call something like
(your-child-form-type)this.MdiChildren(your-child-form-index).Save()
if you ever have one form opened at the time then this index is always 0


Correct solution would be to have all children implementing an interface so that you could add any child form you want that implements that interface and call its save button.

Alternatively, you could have all children inherit from base abstract class containing Save method that must be implemented in each child.


这篇关于如何在mdi父保存按钮单击事件上保存子表单文本框输入值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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