锘??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 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 西吉县| 沈丘县| 昌宁县| 电白县| 怀远县| 通城县| 英吉沙县| 阿拉善右旗| 涟源市| 电白县| 泸溪县| 辉南县| 山东| 伊宁县| 太保市| 喀喇沁旗| 木兰县| 油尖旺区| 建水县| 建德市| 达尔| 连云港市| 丹寨县| 溧水县| 澜沧| 宜昌市| 乌鲁木齐县| 漯河市| 南宁市| 本溪市| 阳谷县| 金阳县| 甘谷县| 隆安县| 兴义市| 平江县| 晋江市| 辛集市| 阿克苏市| 库尔勒市| 陕西省|