可在C窗口的load事件中写处理过程,如果要获得A中的数据,则可将A中所需的数据变为static类型来访问。

解决方案 »

  1.   

    //你可以这样写一下看看吧Form Form2 = new Form2();Form2.Text= textBox1.Text;
    ......  //你的事务处理代码 ,在Form2模式显示之前执行Form2.ShowDialog();......  //这里的代码要在模式窗体关闭以后才可以执行
      

  2.   

    //////////////////////////////////////////////////////////////
    我想我可以在窗体C的代码中去处理这些事情,问题是我模式的显示C后,立刻就要执行这段代码,我该把这段代码放哪儿,或者说是哪个函数,哪个事件处理中呢???
    //////////////////////////////////////////////
    你放在Form_Load事件里不行么?
      

  3.   

    在Form_paint事件里添加就可以了啊
      

  4.   

    在Form_Load中
    不行,我试过了
    Form_paint也
    不行啊,如果我移动了窗体呢??
      

  5.   

    在Form_Load中不行,你可以在窗体C的构造函数里写
      

  6.   

    其实如果想简单点:可以用Form2.Show(),设置Form2的TopMost = true.显示Form2后,把后来的窗体Disabel掉就可以了,这样弹出的窗体会一直在前面,而后面的窗体不能被操作。
      

  7.   

    在窗体C的构造函数里写?肯定不行啊,明显的,应该在窗体的构造函数之后阿如果在构造函数里写,那结果肯定是等待很长时间窗体才出来,而且,事情都已经处理完了, 然后RichTextBox里显示所有的信息,这与我的本意不符合阿??
      

  8.   

    另外一个方法,你弹出窗体如果只是为了显示一个进度条的话。可以用GroupBox或者Panel,把进度条放在面板中,这样可以用Visible属性控制面板否显示阿。如果觉得效果不是太好,用两个面板,一个做阴影。
      

  9.   

    Q1:我想在不用多线程的情况下,应使用非模式窗体并奖TopMost = true。
    Q2:在.net里TEXTBOX等的增加用AppendText()方法:
    textBox1.AppendText("appendtext\n");
    其中“\n”是换行符,如果不想换行,请将其去掉。
    关于字符转义请参阅帮助:
    ms-help://MS.VSCC/MS.MSDNVS.2052/cpgenref/html/cpconcharacterescapes.htm
      

  10.   

    我是这样处理的:
    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;namespace WindowsApplication4 {
        public interface IDoWork{       //回调接口
            void DoWork();}    public class Form1 : System.Windows.Forms.Form,IDoWork {
            private System.Windows.Forms.Button button1;
            private System.ComponentModel.Container components = null;
            private Form2  mfrm2=null;        public Form1() {
                InitializeComponent();
            }        protected override void Dispose( bool disposing ) {
                if( disposing ) {
                    if (components != null) {
                        components.Dispose();
                    }
                }
                base.Dispose( disposing );
            } #region Windows Form Designer generated code
            /// <summary>
            /// 设计器支持所需的方法 - 不要使用代码编辑器修改
            /// 此方法的内容。
            /// </summary>
            private void InitializeComponent() {
                this.button1 = new System.Windows.Forms.Button();
                this.SuspendLayout();
                // 
                // button1
                // 
                this.button1.Location = new System.Drawing.Point(176, 88);
                this.button1.Name = "button1";
                this.button1.Size = new System.Drawing.Size(152, 32);
                this.button1.TabIndex = 0;
                this.button1.Text = "button1";
                this.button1.Click += new System.EventHandler(this.button1_Click);
                // 
                // Form1
                // 
                this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
                this.ClientSize = new System.Drawing.Size(440, 317);
                this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                              this.button1});
                this.Name = "Form1";
                this.Text = "Form1";
                this.ResumeLayout(false);        }
    #endregion        [STAThread]
            static void Main() {
                Application.Run(new Form1());
            }        private void button1_Click(object sender, System.EventArgs e) {
                mfrm2=new Form2();
                mfrm2.objServer=this;
                mfrm2.ShowDialog();
            }        public void DoWork(){
                mfrm2.label1.Text ="Do Work";
            }
        }    public class Form2 : System.Windows.Forms.Form {
            public System.Windows.Forms.Label label1;
            public IDoWork objServer=null;
            private bool blnAtDoWork=false;
            private System.Windows.Forms.Timer timer1;
            private System.ComponentModel.IContainer components;        public Form2() {
                InitializeComponent();
            }        protected override void Dispose( bool disposing ) {
                if( disposing ) {
                    if(components != null) {
                        components.Dispose();
                    }
                }
                base.Dispose( disposing );
            } #region Windows Form Designer generated code
            /// <summary>
            /// 设计器支持所需的方法 - 不要使用代码编辑器修改
            /// 此方法的内容。
            /// </summary>
            private void InitializeComponent() {
                this.components = new System.ComponentModel.Container();
                this.label1 = new System.Windows.Forms.Label();
                this.timer1 = new System.Windows.Forms.Timer(this.components);
                this.SuspendLayout();
                // 
                // label1
                // 
                this.label1.Location = new System.Drawing.Point(32, 16);
                this.label1.Name = "label1";
                this.label1.Size = new System.Drawing.Size(224, 16);
                this.label1.TabIndex = 0;
                this.label1.Text = "正在... ...";
                // 
                // timer1
                // 
                this.timer1.Interval = 1000;
                this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
                // 
                // Form2
                // 
                this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
                this.ClientSize = new System.Drawing.Size(280, 48);
                this.ControlBox = false;
                this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                              this.label1});
                this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
                this.Name = "Form2";
                this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
                this.Text = "Form2";
                this.Activated += new System.EventHandler(this.Form2_Activated);
                this.ResumeLayout(false);        }
    #endregion        private void Form2_Activated(object sender, System.EventArgs e) {
                if(!blnAtDoWork){
                    blnAtDoWork =true;
                    objServer.DoWork();
                    timer1.Enabled=true;
                }
            }        private void timer1_Tick(object sender, System.EventArgs e) {
                this.Close();
            }
        }}
    !!首先,你在DoWork后调用Close()是没有用的。 这里的计时器设置为1秒,是为演示的目的。
      

  11.   

    也可以不使用Activated事件,直接设置计时器一开始就有效,在第一次触发事件时,立即关闭计时器,后面的事情就一样了。
      

  12.   

    使用非模式窗体并奖TopMost = true这肯定不行,因为在显示信息的时候还可以操作别的菜单,这与我的初衷不符。
    使用定时器好像可以,不过我感觉怪怪的,我觉得应该有更好的方法阿
      

  13.   

    我觉得你可以把要在窗体C显示是要执行的代码放在窗体C的FORMLOAD事件中运行。
      

  14.   

    我记得在C++Builder中也不能像你写得那样吧!如果你的窗口显示完进度就关闭的话,你可以ShowDialog后马上Close,把代码添加到Closing事件里就行了!