Form1.cs 1014 B

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace WindowsFormsTextBox
  11. {
  12. public partial class Form1 : Form
  13. {
  14. public Form1()
  15. {
  16. InitializeComponent();
  17. }
  18. private void Form1_Load(object sender, EventArgs e)
  19. {
  20. textBox1.Multiline = true; //设置文本框为多行文本框
  21. //textBox1.Text = "作业星辰昨夜风,画楼西畔桂堂东。身无彩凤双飞翼,心有灵犀一点通。";
  22. //textBox1.Height = 100; //设置文本框的高度
  23. textBox1.SelectionStart = 5; //开始选择的起始位置,从0开始
  24. textBox1.SelectionLength = 5; //选择的长度
  25. }
  26. private void textBox1_TextChanged(object sender, EventArgs e)
  27. {
  28. label1.Text = textBox1.Text;
  29. }
  30. }
  31. }