Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Data Binding / October 2006

Tip: Looking for answers? Try searching our database.

What event can I use on a binding action?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jamie Risk - 30 Oct 2006 17:40 GMT
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

Suggestions?
Jamie Risk - 30 Oct 2006 18:00 GMT
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);

> 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
[quoted text clipped - 12 lines]
>
> Suggestions?
Bart Mermuys - 30 Oct 2006 18:01 GMT
Hi,

> 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.

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

> On my form I have a comboBox and an numericUpDown (spinbox) display.
>
[quoted text clipped - 7 lines]
>
> Suggestions?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.