textBox绑定的问题
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication20
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
re r;
private void Form1_Load(object sender, EventArgs e)
{
textBox1.DataBindings.Add("Text", this, "TimeNow");
}
private string _timeNow = "sdfsf";
public string TimeNow
{
get
{
_timeNow = DateTime.Now.ToString();
return _timeNow;
}
set { _timeNow = value; }
}
private void button1_Click(object sender, EventArgs e)
{
this.TimeNow = DateTime.Now.ToString();
}
}
}
想法很简单,textbox显示系统时间,首先绑定一个属性,当按下button时候,更改这个属性,但是textbox没有改变,还是初始值,这是为什么