110,538
社区成员
发帖
与我相关
我的任务
分享
StringBuilder sb = new StringBuilder(255);
IntPtr win = FindWindow(null, "xxxx管理软件");
//CloseWindow(win);
GetClassName(win, sb, 255);
string className = sb.ToString().Substring(sb.ToString().IndexOf(".app"));
string name = "1";
IntPtr txt = FindWindowEx(win, IntPtr.Zero, "WindowsForms10.EDIT" + className, null);
SendMessage(txt, WM_SETTEXT, IntPtr.Zero, name);
namespace _02窗体传值
{
public partial class Form1 : Form
{
public Form1(string st)
{
InitializeComponent();
textBox1.Text = st;
}
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form2 for2 = new Form2(textBox1.Text);
for2.Show();
Form1 for1 = new Form1(textBox1.Text);
for1.Close();
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
下面是Form2窗体的代码
namespace _02窗体传值
{
public partial class Form2 : Form
{
public Form2(string st)
{
InitializeComponent();
textBox1.Text = st;
}
private void Form2_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
Form1 for1 = new Form1(textBox1.Text);
for1.Show();
}
}
}