event for combobox databinding complete? - vb.net

I have a combobox on a winform, and need to be able to call a method when the combobox's databinding is complete. I am surprised to see that there is no DataBindingComplete event for the ComboBox control, like there is for the DataGridView.
How can I know when data binding is complete? Is databinding done synchronously for comboboxes? (i.e., if I have the following code, is it guaranteed that data binding will be complete when it hits the second line of code?)
myComboBox.DataSource = foo
SomeMethod()

You could make a class where you handle all the data access, then as the data is retrieved you can raise an event from that layer to the calling form you use to display your data.
Data Access Layer

Related

ComboBox event that runs after BindingSource has updated

I am using a ComboBox tied to a BindingSource.
After selecting the appropriate choice, I need a bunch of things to happen, but the BindingSource needs to be up to date first, in other words the current record needs to be fully loaded before continuing.
I am currently using the DropDownClosed event, but other TextBoxes bound to the same binding source haven't updated yet. Is there another event I can use?

Which events are raised when a form is showned after it was hiding (vb.net)

In my vb.net project, I navigate between forms.
I have a main form in which I can display new forms and modify some information in them.
When I closed these new forms, the main form, previously hidden by using the form.hide() method, is displayed by the form.show() method and should consider these modifications.
In order to do that I need to know which event(s) is(are) raised when a form is shown by the form.show() method.
I already try to use the form.show event but it is only raised when the form is firstly showned at the start.
When switching between .Hide() and .Show() the VisibleChanged event is raised.
If you want a more robust method (albeit more code), you can overload your form's Show method.
Public Overloads Sub Show(Optional ByVal getData As Boolean = False)
If getData Then
'get data from other form
End If
MyBase.Show()
End Sub
Your form will act normally, except in the case where you call it from your secondary forms, in which case your extra code is called, like so:
myMainForm.Show(True)
This method would be preferred in cases where you might be show/hide-ing the form, but do not want your extra code to be called every time.

What event fires when bound controls are refreshed?

Can you tell me what event fires when individual textboxes that are bound to a data source using the properties pane gets refreshed?
I wish to use this event to populate a few textboxes that are not bound.
It depends on what property control is bound, usually textboxes are bound on Text property, so your "event" is TextChanged event

VB.net: How do I "refresh" my comboBox?

I have a combobox that is populated by a database table I have. In my Load event for my form I have it populated by...
Me.BusinessTableAdapter.Fill(Me.BillingdbDataSet.Business)
My problem is whenever I "add", "edit", or "delete" a business I have stored I can't find a way to update the combobox I have. Whenever I exit and reopen my program and I can see the changes but was hoping someone could inform me on how to have it updated after a change has happened.
The problem is you need something that implements INotifyCollectionChanged.
MSDN
You can enumerate over any collection
that implements the IEnumerable
interface. However, to set up dynamic
bindings so that insertions or
deletions in the collection update the
UI automatically, the collection must
implement the INotifyCollectionChanged
interface. This interface exposes the
CollectionChanged event, an event that
should be raised whenever the
underlying collection changes.
You can refresh it manually, but the ideal situation is the bind to an observable collection class - http://msdn.microsoft.com/en-us/library/ms668604.aspx HTH
Wade
If you're using datasets you can use the dataview class which raises events when the underlying dataset is changed. Then you could either look into data binding them to the combo-box or write your own update code and put that in an event handler for the event raised when the list changes.

PropertyChanged Event, raise when OnClick?

I have a WinForms application with some business objects which implement INotifyPropertyChanged and hook the PropertyChanged event via some controls & BindingSource on the form which raises an event back to my business objects layer...
There's just one issue - everything works fine, except only when the control loses focus. E.G., the user changes some text field, but he has to actually click on some other control somewhere BEFORE he hits the 'save' button (e.g. he has to cause focus on another control).
Is there a way to wire this up to OnClick or something so the change is propogated to my business objects layer as the user types the text (or even after he changed a drop down value) so I don't have to force the user to click on a different text box before he can save?
Googling has lead me nowhere but to examples on how to easily do this in WPF =(. But no WinForms examples...
Please Advise,
Drew
If you are using Binding class to connect object to UserControl, you may try to set binding's DataSourceUpdateMode to OnPropertyChanged.
Please, note that in this way you are writing data to your object before validation. This may be unsuitable for some tasks.