[問題] 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