锘??xml version="1.0" encoding="utf-8" standalone="yes"?>中文字幕精品一区,神马久久午夜,亚洲一区免费视频http://www.aygfsteel.com/programmer/category/27887.htmlzh-cnFri, 07 Dec 2007 06:21:51 GMTFri, 07 Dec 2007 06:21:51 GMT60Refresh related controls' value when data changed using DataBind in Winformhttp://www.aygfsteel.com/programmer/archive/2007/08/29/165569.htmlwadewadeWed, 29 Aug 2007 02:31:00 GMThttp://www.aygfsteel.com/programmer/archive/2007/08/29/165569.htmlhttp://www.aygfsteel.com/programmer/comments/165569.htmlhttp://www.aygfsteel.com/programmer/archive/2007/08/29/165569.html#Feedback0http://www.aygfsteel.com/programmer/comments/commentRss/165569.htmlhttp://www.aygfsteel.com/programmer/services/trackbacks/165569.htmlGoal:

Use a ComboBox to select an item, and save the selected item's value to some textboxes. each control is using databinding.

Problems:

1. set control's value when comboBox changed, after the comboBox lost focus, the text was lost since the controls reload the data from binding source.

2. set binding source's value, the text will be set only when the comboBox lost focus. but we want to set the text immediately when the comboBox changed.

Solution:

set binding source's value, and call comboBox's writeValue for comboBox. this will write the comboBox's value to datasource, and reload all controls' value.

Test selectedTest = (Test)comboBox1.SelectedItem;

Test test = (Test)bindingSource1.DataSource;
if (selectedTest == null || test == null)
return;

//save the selected value to the binding source test.Name = selectedTest.Name; test.Value = selectedTest.Value; //this will write the comboBox's value to datasource, and reload all controls' value comboBox1.DataBindings["SelectedValue"].WriteValue();

 


wade 2007-08-29 10:31 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 昌宁县| 连云港市| 历史| 当阳市| 东丰县| 蓝田县| 双鸭山市| 梁河县| 高雄县| 石台县| 文昌市| 彝良县| 类乌齐县| 张北县| 张掖市| 永昌县| 筠连县| 蒲江县| 蓝山县| 同江市| 长岛县| 游戏| 拉萨市| 灵山县| 甘肃省| 兰考县| 克什克腾旗| 新绛县| 罗定市| 含山县| 馆陶县| 抚州市| 景泰县| 东阿县| 手游| 瑞昌市| 桐梓县| 临洮县| 迁安市| 平陆县| 进贤县|