我有两个winform1,winform2
winform1中使用了树控件 定义了GetTreeText()方法得到选中Node的text问题是winform2 怎么去调用GetTreeText()方法,请大家赐教来者有分!
winform1中使用了树控件 定义了GetTreeText()方法得到选中Node的text问题是winform2 怎么去调用GetTreeText()方法,请大家赐教来者有分!
解决方案 »
- 从VS2008中浏览ASPX页面时,浏览器说Internet Explorer 无法显示该页面???
- 关于FileUpload1.PostedFile.FileName;问题(70)分
- 求一个提示方法
- 求asp.net连接数据库的几种方式
- 救助高人!如何实现软件试用的功能
- asp.net里面使用jmail组件,系统是否需要安装,还是可以直接web引用jmail.dll就可以了?
- 如何判断用户上传的文件是 RAR 类型? 不要用扩展名方法
- Ajax1.0怎样调用非静态C#类方法?
- 什么是代理类?作用?怎么写?
- 中文注释内容在Asp.Net Matrix的代码或HTML编辑器里显示的是乱码,为什么?如何解决?谢谢~!
- 在win2000中发布ASP.NET的问题
- Visual Studio.net 已检测到指定的WEB服务器运行的不是ASP。NET1.1版。你将无法运行ASP。NET应用程序或服务
if (frm.ShowDialog(this).DialogResult==DialogResult.OK)
{
MessageBox.Show(frm.GetTreeText());
}
我的本意是
winform1 是个父窗口
winform2 是个搜索窗口
就象记事本一样
搜索结果选定树的Node
这种方法不行
他新建了一个winform1对象
不能取得当前树选中的Node
其它地方调用.... public static string s;调用时 类名.s 注意是是类名啊.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;namespace WindowsApplication3
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
private System.Windows.Forms.Button button2;
public static string s; //注意这 public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.button2 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button2
//
this.button2.Location = new System.Drawing.Point(104, 160);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(80, 40);
this.button2.TabIndex = 1;
this.button2.Text = "button2";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.button2);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false); }
#endregion /// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
} private void Form1_Load(object sender, System.EventArgs e)
{
}
private void button2_Click(object sender, System.EventArgs e)
{
s="100"; Form2 frm=new Form2();
frm.Show ();
}
}
}
// form2 using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;namespace WindowsApplication3
{
/// <summary>
/// Form2 的摘要说明。
/// </summary>
public class Form2 : System.Windows.Forms.Form
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null; public Form2()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
//
// Form2
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Name = "Form2";
this.Text = "Form2";
this.Load += new System.EventHandler(this.Form2_Load); }
#endregion private void Form2_Load(object sender, System.EventArgs e)
{
MessageBox.Show ("传过来的值为:"+Form1.s .ToString());
}
}
}