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 WindowsFormsTextBox { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { textBox1.Multiline = true; //设置文本框为多行文本框 //textBox1.Text = "作业星辰昨夜风,画楼西畔桂堂东。身无彩凤双飞翼,心有灵犀一点通。"; //textBox1.Height = 100; //设置文本框的高度 textBox1.SelectionStart = 5; //开始选择的起始位置,从0开始 textBox1.SelectionLength = 5; //选择的长度 } private void textBox1_TextChanged(object sender, EventArgs e) { label1.Text = textBox1.Text; } } }