代码:
ComboBox comboBox = new ComboBox();
comboBox.DataBindings.Add(new Binding("SelectedItem", "", null));
Debug.WriteLine($"Bindings count = {comboBox.DataBindings.Count}");
comboBox.ResetBindings();
Debug.WriteLine($"Bindings count = {comboBox.DataBindings.Count}");
输出:
Bindings count = 1
Bindings count = 0
MSDN说“导致绑定到BindingSource的控件重新读取列表中的所有项目并刷新其显示的值。”
答案 0 :(得分:0)
好吧,看来MSDN确实不准确。
真正使源代码产生控件更新值的是
comboBox.DataBindings[0].ReadValue();