zoukankan      html  css  js  c++  java
  • c# 窗体之间传递值 转载

    转载自: http://www.wangchao.net.cn/it/detail_52411.html

    代码
    父窗口:
      
    using System;
      
    using System.Collections.Generic;
      
    using System.ComponentModel;
      
    using System.Data;
      
    using System.Drawing;
      
    using System.Text;
      
    using System.Windows.Forms;
      
    namespace mail
      ...{
      
    public partial class Form1: Form
       ...{
      
      
      
    private string searchUrl = null;
      
    public Form1()
       ...{
       InitializeComponent();
       }
      
    public string SearchUrl
       ...{
      
    get
       ...{
      
    return searchUrl;
       }
      
    set
       ...{
       searchUrl
    = value;
       }
       }
      
    private void Form1_Load(object sender, EventArgs e)
       ...{
       Form2 form2
    = new Form2();
       form2.Owner
    = this;
       form2.ShowDialog();
       }
       }
      }
      子窗口:
      
    using System;
      
    using System.Collections.Generic;
      
    using System.ComponentModel;
      
    using System.Data;
      
    using System.Drawing;
      
    using System.Text;
      
    using System.Windows.Forms;
      
    namespace mail
      ...{
      
    public partial class Form2: Form
       ...{
      
    public Form2()
       ...{
       InitializeComponent();
       }
      
    private void setParent()
       ...{
       Form1 f
    = (Form1)this.Owner;
       f.SearchUrl
    = "www.baidu.com";
       }
       }
      }(王朝网络 wangchao.net.cn)
  • 相关阅读:
    6.7
    6.5
    6.4随笔
    js 插件
    js插件
    web中集成jdbc
    jsp
    web容器中的servlet
    web服务器的监听器,过滤器
    几款js工具的使用
  • 原文地址:https://www.cnblogs.com/wenjie/p/1868103.html
Copyright © 2011-2022 走看看