帮助有关主表单及其子表单之间的交互操作 [英] help about Interactive operation between main forms and its child forms

查看:52
本文介绍了帮助有关主表单及其子表单之间的交互操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很困惑如何实现主表单及其子表单之间的交互操作.例如,我的项目中有一个主表单和子表单.
主要形式如下(仅是一个简化示例):

I''m confused how to realize the interactive operation between main forms and its child forms.for example there is a main form and child form in my project.
the main form is below(just a simplified example):

namespace WindowsFormsApplication1
{
    partial class Form1
    {
        private System.ComponentModel.IContainer components = null;

        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        private System.Windows.Forms.Button button1;
        private System.Windows.Forms.RichTextBox richTextBox1;
        private System.Windows.Forms.StatusStrip statusStrip1;
        private System.Windows.Forms.ToolStripProgressBar toolStripProgressBar1;
        private System.Windows.Forms.Label label1;
    }
}


单击主窗体上的button1时,将显示一个子窗体,然后用户可以通过单击子窗体上的按钮来开始对硬盘上的记录文件进行分析.同时
子窗体上有一些复选框,可提供记录文件分析中使用的条件.
我要达到的目的是:在分析和进度条过程中,中间结果和最终结果都显示在主窗体的ricktextbox1中.
在主窗体上将显示处理进度.
如果以上所有内容都以一种形式进行操作,我可以处理.如何进行分析
对子窗体进行操作并在主窗体上显示信息,因为必须完成许多分析和模拟工作,因此我的项目中有很多子窗体,我想在同一位置显示所有这些分析结果(主窗体上的richtextbox1)并非在每个子窗体上都使用


When button1 on main form is clicked ,one child form will show ,then user may start the analysis of record file on hard disk by clicking button on child form.Meanwhile
there are some checked box on child forms which supply for the conditions used in record file analysis.
The purpose i want to achieve is :the intermediate and final results are all displayed in the ricktextbox1 on main form during the analysis and the progressbar
on main form will show the processing progress.
I can deal with it if all of above is operated on one form. how can i run analysis
operation on child form and show information on main form because there are many analysis and simulation works must be done,so there are many child forms in my projects and i want to show all these analysis results on the same place(richtextbox1 on main form) not on every child forms

推荐答案

亲爱的朋友

这很容易
请按照以下步骤操作
1.在子表单上创建一个完整的事件
2.在子加载时初始化该事件
dear friend

it is very easy
follow these steps
1. Create a complete event on child form
2. initialize that event on child load
FrmChild frmcs = new FrmChild();
frmcs.OnComplete += new FrmCSet.GetDetail(getdetail);
frmcs.ShowDialog();


3.在子&上完成的流程上执行该事件.它将更新主表格


3. execute that event on process complete on child & it will update main form

private void getdetail(string strData)
 {
 richTextBox1.text =richTextBox1.text + strdata;

}


这篇关于帮助有关主表单及其子表单之间的交互操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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