在c#中点击主窗体的控件,调用子窗体,并在子窗体中显示内容??

比如说,子窗体中有一个文本框,我要调用子窗体,并且要在子窗体文本框中显示一定的内容,请高手给我详细代码,高手来。
最新回答
旧事酒浓

2024-05-04 00:03:55

添加一个窗体,名为form2,原窗体名为form1,工程名为 form ,双击Form2.Designer.cs:将 private System.Windows.Forms.TextBox textBox1; 改为:public System.Windows.Forms.TextBox textBox1; form1中的命令按钮的单击代码: using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace form
{
public partial class Form1 : Form
{
public Form2 f2 = new Form2();
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
f2.Owner = this;
f2.textBox1.Text = "ffddsf";
f2.ShowDialog();
}
}
}
好感都给你

2024-05-04 05:13:26

www.iav8d.com/?post=4

有详细的步骤
玥天竺灭仄

2024-05-04 05:24:29

创建子窗体时 顺便给传个值就是咯