zoukankan      html  css  js  c++  java
  • C# Winfrom 页面传值

    2个窗体 Parent,Children

    代码:

    Parent

    public partial class Parent : Form
        {
            public string parentValue = "parentValue";
    
            Children sw;
    
            public  Children cc;
    
            public Parent()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                //sw = new Children();
                //sw.Owner = this;
                //sw.Show();
    
    
                //sw = new Children();
                //sw.childrenValue = "childrenValue";
                //sw.Show();
    
                sw = new Children();
                sw.pp = this;
                sw.Show();
            }
        }

    Childrent

        public partial class Children : Form
        {
            public string childrenValue { get; set; }
    
            public Parent pp;
    
            public Children()
            {
                InitializeComponent();           
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
               // Parent c = (Parent)this.Owner;
               // MessageBox.Show(c.parentValue);
    
               //MessageBox.Show(childrenValue);
    
                MessageBox.Show(pp.parentValue);
            }
        }

    当然这里还有static 事件等等方式传值。

    核心总结:

    winfrom窗体传值 其实就是类 Parent和Children 之间传递  页面最终也是生成类对象。 

  • 相关阅读:
    AddParent
    AddChild
    贝塞尔曲线代码
    顶点纹理shader
    抽象方法与抽象类
    Application类
    布局组件
    C#单例和Unity单例
    Unity&UGUI
    Json解析
  • 原文地址:https://www.cnblogs.com/y112102/p/3723044.html
Copyright © 2011-2022 走看看