- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Windows.Forms;
- namespace WindowsFormsApplication1
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- Thread th = new Thread(ChangeTextBox);
- th.IsBackground = true;
- th.Start();
- }
- public bool flag = true;
- public void ChangeTextBox()
- {
- this.Invoke(new Action(() =>
- {
- this.textBox1.Width = (int)(this.textBox1.Width * (flag ? 2 : 0.5));
- flag = !flag;
- }));
- }
- }
- }
- 原创https://blog.csdn.net/yenange/article/details/51870133