11
I saw the answer in Databound Windows Forms control does not recognize change until losing focus.
But this doesn't fully answer the question for me. I have the exact same situation. On ToolStrip_click, I go through all of my controls and I force "WriteValue()", but it still reverts to the previous value before the save. Can anyone suggest how I can fix this? Did I implement this incorrectly?
(See code for current (non-working) solution.)
private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
// Make sure that all items have updated databindings.
foreach (Control C in this.Controls)
{
foreach (Binding b in C.DataBindings)
{
// Help: this doesn't seem to be working.
b.WriteValue();
}
}
}
The code is now much simpler, but it is a considerable hack. I'd be very happy to know if there is a more "proper" fix for this.
private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
// Make sure that all text fields have updated by forcing everything
// to lose focus except this lonely little label.
label44.Focus();
}