VB题。在文本框中输入内容,然后单击命令按钮,在文本框中输入的内容同时显示在标签和命令按钮上。

如题所述

先假设条件为:窗体一名称为Form1,其中文本框为text1;窗体二名称为Form2,其中文本框为text1.
窗体一上面的代码为:
private Sub Text1_Change() ‘注意这里是change
Form3.Label1.Caption = Form3.Label1.Caption & Text1.Text
end Sub

窗体二上面的代码为:
private Sub Text1_Change()
Form3.Label1.Caption = Form3.Label1.Caption & Text1.Text
end Sub

这样在窗体一或者二的文本框中输入内容时,窗体三上面的label标签的内容也会随之变化啦。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2017-05-19
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication5
{
public partial class Form1 : Form
{
string s;
public Form1()
{
InitializeComponent();
}

private void radioButton1_Click(object sender, EventArgs e)
{
s = textBox1.Text;
}

private void radioButton2_Click(object sender, EventArgs e)
{
s = textBox2.Text;
}

private void button1_Click(object sender, EventArgs e)
{
label1.Text = s;
}

private void Form1_Load(object sender, EventArgs e)
{
textBox1.MaxLength = 6;
textBox2.PasswordChar = '*';
}
}
}