views:

17

answers:

1

I have a combobox that is databound and updates with no issues. The problem I have is if the user types something into the combobox and then uses the [X] close button in the window without tabbing out, the data is not updated. I've been looking all over the web, but can't find any relevant help/tips. The only idea is have is to force an out of focus and maybe that would force the combobox to see the update.

A: 

Try adding the FormClosing event on your form.

The FormClosing event occurs as the form is being closed.

private void Form1_FormClosing(Object sender, FormClosingEventArgs e) 
{    
  //force an event to have the cbo updates fire.
  txtFoo.Focus();
}

or VB.NET

Private Sub Form1_FormClosing(sender as Object, e as FormClosingEventArgs) _ 
     Handles Form1.FormClosing

    'force an event to have the cbo updates fire.
     txtFoo.Focus()
End Sub

From there, you can call the method/logic to have your combobox's contents saved to your datastore.

p.campbell
Since it is already databound, I am trying for the combobox to update the datasource. I have about 30 or so comboboxes and multiple forms were this is a problem. I am hoping there is some other fix/workaround so I don't have to handle manually updating. Thx for help though.
B Z
@B Z: indeed, is there a method that can be called on that combobox to trigger its update back to the datasource? i.e. what event or method could be called to ensure it updates? Almost like the same event as the Enter key would call while typing in the combobox.
p.campbell
If i focus on a separate control, the combobox updates.
B Z