Groups | Blog | Home
all groups > dotnet windows forms databinding > october 2006 >

dotnet windows forms databinding : What event can I use on a binding action?



Jamie Risk
10/30/2006 11:40:57 AM
I've got a comboBox bound to an object in my code. Is there an
event I can hook when the object is updated? I can break on the
"set mydata = value;" but I'm not clever enough to know what
event triggered that call.


On my form I have a comboBox and an numericUpDown (spinbox)
display.

The binding of the spinbox is selected by the comboBox. The
comboBox itself is bound to it's own data element.

The approach I've taken is to look at the comboBox events:
selectedIndexChanged
selectedValueChanged
Leave

Jamie Risk
10/30/2006 12:00:43 PM
I think I found it:

Instead of:
mycomboBox.DataBindings.Add(
new Binding("Text", myList, "Description));

I'll try:
Binding myBinding = new Binding("Text", myList, "Description));
myBinding.Parse +=
new ConvertEventHandler(this.mycomboBox_Binding_Parse);
mycomboBox.DataBindings.Add(myBinding);

[quoted text, click to view]
Bart Mermuys
10/30/2006 5:01:37 PM
Hi,

[quoted text, click to view]

Checkout BindingSource.BindingComplete or Binding.BindingComplete, it will
be fired each time the DataSource or the Control is updated, check the
parameters to determine the direction.

eg.:

comboBox.DataBindings["SelectedValue"].BindingComplete+= new
BindingCompleteEventHandler(OnComboBoxBindingComplete);

private void OnComboBoxBindingComplete( object sender,
BindingCompleteEventArgs e)
{
if ( e.BindingCompleteContext ==
BindingCompleteContext.DataSourceUpdate )
{
comboBox cb = (ComboBox)e.Binding.Control;
....
}
}

HTH,
Greetings

[quoted text, click to view]

AddThis Social Bookmark Button