Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > Custom Business Object Data Binding Warning
 

Custom Business Object Data Binding Warning

I've implemented a simple Employee object:

public class Employee : INotifyPropertyChanged
{
  
private string name = "Foo";
  
public event PropertyChangedEventHandler PropertyChanged;

  
public string Name
   {
      get { return name; }
     
set{  name = value; OnPropertyChanged("Name"); }
   }

   protected virtual void OnPropertyChanged(string propertyName){  
      if(PropertyChanged != null){
         PropertyChanged(
this, new PropertyChangedEventArgs(propertyName));
   }
}

I then bind Employee.Name to a TextBox.Text using an ObjectBindingSource.  Everything works fine, but I get the following warning:

"Events cannot be set on the object passed to the event binding service because a site associated with the object could not be located."

If I make Employee an IComponent then this warning goes away.  Is there anyway to remove this warning without you business object having to be a Component?

Thanks, Jim

Jim Walkling  Thursday, June 23, 2005 12:52 AM

Please log a bug on this issue here: http://lab.msdn.microsoft.com/productfeedback/default.aspx.  Please include as much context as you can (a repro application would be ideal). 

Thank you,

Joe Stegman
The Windows Forms Team
Microsoft Corp.

This posting is provided "AS IS" with no warranties, and confers no rights.

Joe Stegman  Friday, June 24, 2005 2:34 PM

I'm not clear on why you're seeing this error as you do not need to implement IComponent to get this to work.  Is the error happening at runtime or design time?  I am able to bind to the business object without errors using the following steps:

Added the Employee type above to a project
Added the Employee type as a DataSource

   With the Form visible in the designer:

      Data -> Add New Data Source...
      Select Object
      Drill down to select the Customers object
      Click Finish
   
   Bind the "Name" property to a TextBox

      Data -> Show Data Sources
      Drag the "Name" column to the Form (TextBox auto-generated)

   Run the application

What are you doing that's different from this?

Joe Stegman
The Windows Forms Team
Microsoft Corp.

This posting is provided "AS IS" with no warranties, and confers no rights.

Joe Stegman  Friday, June 24, 2005 1:19 AM
I get the exact same warning when running a project converted from VS.NET 2003. And the warning comes about 11000 times, all on line 0, column 0. Really love those errormessages which have exactly NO value whatsoever.
Qllie  Friday, June 24, 2005 1:29 PM

Please log a bug on this issue here: http://lab.msdn.microsoft.com/productfeedback/default.aspx.  Please include as much context as you can (a repro application would be ideal). 

Thank you,

Joe Stegman
The Windows Forms Team
Microsoft Corp.

This posting is provided "AS IS" with no warranties, and confers no rights.

Joe Stegman  Friday, June 24, 2005 2:34 PM

You can use google to search for other answers

Custom Search

More Threads

• DataGridView, how to capture a cell's KeyPress event...
• DataGridView Fill problem
• two-way binding to textbox (with binding source) - need help
• BindingSource CurrentChanged Event fires 4 times on startup? Why?
• DGV EventHandler for CB
• Filling Typed Dataset using custom object collection
• what is standard way for Save/Retrive Color type into/from windows registry?
• How To set DataSource to global DataSet and edit columns etc. in Design View
• How to display Text property on the new row of a datagridview button column?
• Difficult databound DataGridView filtering scenario