using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
button1.Text = "根据单选按钮,将对应文本框的内容显示在标签内";
textBox1.MaxLength = textBox2.MaxLength = 6;
radioButton1.Text = "取第一个文本框的内容";
radioButton2.Text = "取第二个文本框的内容";
textBox2.PasswordChar = '*';
}
string text;
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
text = textBox1.Text;
}
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
text = textBox2.Text;
}
private void button1_Click(object sender, EventArgs e)
{
label1.Text = text;
}
}
}
![C#文本框实例2 C#文本框实例2](https://image.shishitao.com:8440/aHR0cHM6Ly93d3cuaXRkYWFuLmNvbS9pbWdzLzMvNS84LzAvNTkvMzc0MmNjMWFhZjE4YzFkZjE4NTZiODM5MmE5NWU5NWUuanBl.jpe?w=700&webp=1)