I would like to make a class based on interfaces such as a list (or binding list) to store data that will be used with a datagridview
My question is when designing such code how can I easily find out what methods I need to implement to provide the required functionality and which interfaces need to be inherited (eg ICloneable, IComparible, IList, , IEnumerator, etc, etc)?
or another why of putting it, when inheriting a interface how can I easy find out which methods need to be custom written? does visual studio offer tools that help? obviously many methods will use generics and may not necessarily need rewriting.
A开发者_高级运维lso how can I easily find out what methods (and there interfaces) a datagridview will call from its data source?
I have used a datagridview as an example, however, would be grateful of generic solutions that I can use in other areas in the future and learn from.
At the moment I am a bit overwhelmed when it comes to where to start and finding this information. Surely visual studio (express) has some functionality that can help?
I am not sure I understand your question...
If a class implements an interface, it must implement ALL members defined by the interface.
The most important thing for a DataGridView is to provide a correct DataSource. Have a look into the documentation:
http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.datasource.aspx
As written there, a DataSource must implement just one of the following interfaces:
- IList
- IListSource
- IBindingList
- IBindingListView
Using Visual Studio, as soon as you type
public class MyClass : IBindingList
you will be offered a "smart tag", where Visual Studio suggests to make an empty implementation for all of your interface methods automatically.
You can also use .net Reflector to view the microsoft control asemblies. It will show you all base classes and interfaces controls implement. Failing that MSDN usually has good documentation on all its controls.
DataGridView details can be found at: http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.aspx
精彩评论