[问题] tabcontrol and binding source

楼主: amidofun   2014-07-27 14:38:55
我有一个tabcontrol
有两个tabpage
按照这篇作法 储存表单的资料
http://www.dotblogs.com.tw/yc421206/archive/2011/07/08/31290.aspx
tabpage1有一个config1.xml
tabpage2有一个config2.xml
我在formload的时候依序执行两个function
function1()是负责读取config1.xml for tabpage1,内容为:
BindingList<Config> configs = null;
if (File.Exists("Configs1.xml"))
{
configs = XmlSerialize.DeserializeFromXml<BindingList<Config>>("Configs.xml");
}
else
{
configs = new BindingList<Config>();
configs.Add(new Config() { ProductName = "Test", Axis = "A", Acceleration = 1000, Deceleration = 1000, Speed = 1000, Position = 1000 });
}
this._Source.DataSource = configs;
this.bindingNavigator1.BindingSource = this._Source;
this.dataGridView1.DataSource = this._Source;
this.comboBox1.DataSource = this._Source;
this.comboBox1.DisplayMember = "ProductName";
this.txtDeceleration.DataBindings.Add("Text", this._Source, "Deceleration");
this.txtPosition.DataBindings.Add("Text", this._Source, "Position");
this.txtAxis.DataBindings.Add("Text", this._Source, "Axis");
this.txtAcceleration.DataBindings.Add("Text", this._Source, "Acceleration");
this.txtSpeed.DataBindings.Add("Text", this._Source, "Speed");
同样的function2()是负责读取config2.xml for tabpage2
但是fuction2里面的textbox的text却没有assign到东西 是空的
fuction1却没问题 请问为什么会发生这样的事??

Links booklink

Contact Us: admin [ a t ] ucptt.com