最近在做winform系统时候遇到一个问题,百思不得其解,希望高手可以帮忙解决一下。
如下所示,有一个richtextbox控件,name是rtbZLBB, 后台有一个类, 是ZLBB,现在将richtextbox绑定到ZLBB对象上,但是在输入内容到richtextbox控件的时候,发现无法正常的追加输入,每一次输入光标都是停留在最前面,请问高手这是为什么?进过分析,把Content属性换成private或protected、或者将更新模式参数换成DataSourceUpdateMode.OnValidation、或者将启用格式化参数换成true,就可以正常输入了。请大虾们指教!!!!
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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
ZLBB msg = new ZLBB();
public Form1()
{
InitializeComponent();
rtbZLBB.DataBindings.Add("Text", msg, "Content", false, DataSourceUpdateMode.OnPropertyChanged);
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show(msg.Content);
}
}
class ZLBB
{
public string Content
{
get;
set;
}
}
}