我想在form1中的button中给一个文件夹路径,然后读一个文件就在form2中显示,显示完了就通知form1读下一个文件,所用文件读完又回到第一个文件,并要一直循环。从form2怎么通知form1好。

解决方案 »

  1.   

    干嘛要通知来通知去呢,我认为把form2变成能循环读一个目录的文件并显示不就可以了吗?form1的button传递一个目录给form2而不是目录中的一个文件。
      

  2.   

    因为form1要加工文件内容,然后才交给form2显示
      

  3.   

    委托 +事件...1:定义一个委托的类:
      using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Data;
    using System.Data.SqlClient;namespace EIP
    {
        public delegate void DelegateEvent(string ttt);}
    ==============
    2:窗体2中代码
          public event DelegateEvent refreshData;//生明一个委托的事件
         
         // 当你在数据保存后窗体2数据刷新...
       void  btn_click()
       {
         string tt = "ttt";
                this.refreshMethod(tt);
        }3:================================在你想要刷新的窗体的动作
      form2 frm = new form2();
                            frm.refreshMethod+=new DeletegateTestMethod(refreshMethod);
                frm.ShowDialog();........
    void refreshMethod(string ttt)
    {
    .....
    可以根据窗体2中传来的参数做一些动作...
    }