如何将值从一种MDI形式传递到另一种MDI形式 [英] how to pass value from one mdi form to another mdi form

查看:54
本文介绍了如何将值从一种MDI形式传递到另一种MDI形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨....我比较新鲜....在我的项目中,我使用带有mdI形式的leftmenu ...从一种mdi形式转换为另一种形式,我当时使用按钮单击来打开,我想传递值还...

Form1按钮单击:

private void button1_Click(对象发送者,EventArgs e)
{
Form2 objHomeForm =新的Form2(textbox1.Text);
objHomeForm.Show();

leftmenu lmenuObj =(leftmenu)this.MdiParent;
lmenuObj.closeCurrentForm();
lmenuObj.frmName ="TRANSACTION \\ Form2";
lmenuObj.showMyForm();
}

表格2:

公共Form2(字符串strTextBox)
{
InitializeComponent();
textbox1.Text = strTextBox;
}


我的问题是,在这种情况下如何将值从一种形式传递到另一种形式.... plz帮助....

hi ....i am fresher.... In my project i am using leftmenu with mdI form... From one mdi form to another form i am using button click to open at that time i want to pass value also...

Form1 button click:

private void button1_Click(object sender, EventArgs e)
{
Form2 objHomeForm = new Form2(textbox1.Text);
objHomeForm.Show();

leftmenu lmenuObj = (leftmenu)this.MdiParent;
lmenuObj.closeCurrentForm();
lmenuObj.frmName = "TRANSACTION\\Form2";
lmenuObj.showMyForm();
}

Form2:

public Form2(string strTextBox)
{
InitializeComponent();
textbox1.Text = strTextBox;
}


my problem is how to pass value from 1 form to another form in tis situation....plz help....

推荐答案

这里有两个部分. br/>
首先,这是关于表单协作的流行问题.最健壮的解决方案是在Form类中实现适当的接口,并传递接口引用而不是对Form的整个实例"的引用.请查看我过去的解决方案以获取更多详细信息:如何以两种形式在列表框之间复制所有项目 [ http://en.wikipedia.org/wiki/Multiple_document_interface#Disadvantages [在WPF中使用MDI窗口的问题 [ ^ ],
MDIContainer提供错误 [如何在WPF中创建MDI父窗口? [ ^ ],
如何最大程度地设置子表单,最小化最后一个子表单 [ ^ ].

—SA
There are two parts here.

First, this is the popular question about form collaboration. The most robust solution is implementation of an appropriate interface in form class and passing the interface reference instead of reference to a "whole instance" of a Form. Please see my past solution for more detail: How to copy all the items between listboxes in two forms[^].

Second part is this: stop torturing yourself and scare off your users! Get rid of MDI, this is a really ugly thing discouraged even by Microsoft. I can tell you what to do instead to get much nicer design options which are much easier to implement. Please see:
http://en.wikipedia.org/wiki/Multiple_document_interface#Disadvantages[^],
Question on using MDI windows in WPF[^],
MDIContainer giving error[^],
How to Create MDI Parent Window in WPF?[^],
How to set child forms maximized, last childform minimized[^].

—SA


这篇关于如何将值从一种MDI形式传递到另一种MDI形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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