刚刚接触,想实现textBox1文本每隔一秒就传给另一个textBox2的功能,但是运行不了也不报错,也不能逐行调试。也许这个方法压根就不行吧?那为什么?一定要用线程吗?
//-----------------------------------------------
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 实时显示文本
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string str = "";
for (;true; )
{
str = textBox1.Text;
textBox2.Text = str;
//wait
DateTime now = DateTime.Now;
while (now.AddSeconds(1) > DateTime.Now) { }
}
}
}
}
//-----------------------------------------------
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 实时显示文本
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string str = "";
for (;true; )
{
str = textBox1.Text;
textBox2.Text = str;
//wait
DateTime now = DateTime.Now;
while (now.AddSeconds(1) > DateTime.Now) { }
}
}
}
}