
Signature
Thanks in advance,
Juan Dent, M.Sc.
> What interfaces do I need to implement to accomplish all this?
> any good examples?
I find the following two urls to good resources:
http://msdn2.microsoft.com/en-us/library/41e17s4b.aspx
http://www.dotnet247.com/247reference/msgs/26/133852.aspx

Signature
Kind regards,
Tim Van Wassenhove <url:http://www.timvw.be/>
Hi Juan,
Generally speaking, for a collection, to support the general functionality
of data binding, such as sorting capabilities, change notification and
filtering, you need to implement the IBindingListView, the IBindingList,
the ICollection and the IEumerable interfaces.
.NET 2.0 provides the BindingSource class, which has implmented all the
above interfaces and serves as a powerful data source. You can use the
BindingSource as the data source in your project.
> Also, I want the objects themselves to be data-bindable as well, to
controls such as textboxes and checkboxes and radiobuttons, etc.
You can bind any property of the objects to the WinForms controls, such as
TextBox, CheckBox or RadioButton without implementing any interfaces.
However, to update the data source when the value of the control property
changes, you should specify the DataSourceUpdateMode parameter in the
ControlBindingsCollection.Add method. The following is a sample:
this.textBox1.DataBindings.Add("Text", myObject,
"Name",true,DataSourceUpdateMode.OnPropertyChanged);
On the other hand, to update the control property value when the value in
the data source changes, you should implement the INotifyPropertyChanged
interface for the object's class. The following is a sample:
class Person:INotifyPropertyChanged
{
private string name;
public string Name
{
get { return name; }
set
{
if (value != name)
{
name = value;
propertyChanged(this, new
PropertyChangedEventArgs("Name"));
}
}
}
private event PropertyChangedEventHandler propertyChanged;
#region INotifyPropertyChanged Members
event PropertyChangedEventHandler
INotifyPropertyChanged.PropertyChanged
{
add { propertyChanged += value; }
remove { propertyChanged -= value; }
}
#endregion
}
}
> Additionally, I want to be able to add these objects to the toolbox so I
can drag and drop into Windows Forms.
If your components are defined by a project in the currently open solution,
they will automatically appear in the Toolbox, with no action required by
you. You can also manually populate the Toolbox with your custom components
by using the Choose Toolbox Items Dialog Box (Visual Studio), but the
Toolbox takes account of items in your solution's build outputs with all
the following characteristics:
a. Implements IComponent;
b. Does not have ToolboxItemAttribute set to false;
c. Does not have DesignTimeVisibleAttribute set to false.
For more information on "Automatically Populating the Toolbox with Custom
Components", you may refer to the following MSDN document:
http://msdn2.microsoft.com/en-us/library/fw694kde(VS.80).aspx
Hope this helps.
If you have any question, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Linda Liu [MSFT] - 29 Aug 2007 07:45 GMT
Hi Juan,
How about the problem now?
If you have any question, please feel free to let me know.
Thank you for using our MSDN Managed Newsgroup Support Service!
Sincerely,
Linda Liu
Microsoft Online Community Support