分享

winform窗体传值小结

 乌拉拉1226 2011-01-05
 winform窗体传值小结 收藏
1 用属性传值
(子窗体)
private ArrayList arrlOut;
public ArrayList arrlIn//要用pulibc
        {
            set
            {
                this .arrlOut    = value;//这里不能用arrlIn而要单独声明一个变量
            }
            get
            {
                return this .arrlOut  ;
            }
        }
(主窗体,由它向子窗体传传值)
using System.Collections;//ArrayList引用空间
private  ArrayList arrlOut;
private void btnShowForm4_Click(object sender, EventArgs e)
        {
            Form4 form4StudentInformation = new Form4();           
            form4StudentInformation.arrlIn  = this.arrlOut ;
            form4StudentInformation.Show();
        }
2用方法传值
(主窗体)
using System.Collections;//ArrayList引用空间
private  ArrayList arrlOut;
 private void btnShowForm3_Click(object sender, EventArgs e)
        {
            Form3 formStudentInformation = new Form3();
            formStudentInformation.setArray(arrlOut);
            formStudentInformation.Show();
        }
(子窗体)
private ArrayList arrlOut;
 public  void setArray(ArrayList arrayin)//要用pulibc
        {
            arrlOut = arrayin;
          
        }
3构造函数传值
(子窗体)
 private ArrayList arrlOut;
        public studentOneInformationForm(ArrayList   arrlIn)//构造函数中加了参数
        {
            InitializeComponent();
            arrlOut = arrlIn;
        }
(主窗体)
 private void showFormInformation_Click(object sender, EventArgs e)
        {
            studentOneInformationForm studentOne = new studentOneInformationForm(this.arrlOut);//传参数
            studentOne.Show();
          
        }
 
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/yunazhaozile/archive/2009/12/24/5060735.aspx

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章