文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>c# 窗体之间传递值 --转载

c# 窗体之间传递值 --转载

时间:2010-11-03  来源:wenjie

 

转载自: 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)

 

相关阅读 更多 +
排行榜 更多 +
西安交大通

西安交大通

生活实用 下载
长江云通

长江云通

生活实用 下载
translatez

translatez

生活实用 下载