C
Chuck Cobb
Here's one more question on this topic:
I am developing a CRM system using business objects...I have used the approach we previously discussed to develop lists of business objects for the application and it works great! For example,
- Class ClientInfo defines a business object for a Client
- ClientInfo is inherited from BaseInfo which defines some basic item methods and interfaces such as
- INotifyPropertyChanged
- IEditableObject
- Class ClientList defines a collection of ClientInfo objects
- ClientList is Inherited from BaseList that defines some basic list methods and interfaces such as:
- IBindingListView
- IRaiseItemChangedEvents
- IEditableObject
The problem I'm trying to resolve now has to do with Control binding...At the moment, I have individual controls and datagrids bound directly to each collection of business objects. For example, CtlClients has a datagrid that is bound to the ClientList collection above and other business objects are bound to other controls.
I would also like to use generics in the controls so that I can move some of the common routines into a base control that the other controls inherit from. What I would like to have is something like this:
CtlDataGrid<T> : CtlBase where T : BaseList<BaseInfo> // a general control that supports all business objects, and
CtlClients : CtlDataGrid<ClientList> // a specific control for clients that is inherited from the above
When I define these controls in this way, I get an error message that says "The type ClientList must be convertible to BaseList<BaseInfo> in order to use it as parameter 'T' in the generic type or method CtlDataGrid".
ClientList is inherited from BaseList<ClientInfo> and ClientInfo is inherited from BaseInfo so I'm surprised that the compiler is not able to convert ClientList into BaseList<BaseInfo>. Do I need to write a custom TypeConverter to accomplish that? I attempted to do that, but it didn't seem to make any difference...
Thanks,
Chuck
I am developing a CRM system using business objects...I have used the approach we previously discussed to develop lists of business objects for the application and it works great! For example,
- Class ClientInfo defines a business object for a Client
- ClientInfo is inherited from BaseInfo which defines some basic item methods and interfaces such as
- INotifyPropertyChanged
- IEditableObject
- Class ClientList defines a collection of ClientInfo objects
- ClientList is Inherited from BaseList that defines some basic list methods and interfaces such as:
- IBindingListView
- IRaiseItemChangedEvents
- IEditableObject
The problem I'm trying to resolve now has to do with Control binding...At the moment, I have individual controls and datagrids bound directly to each collection of business objects. For example, CtlClients has a datagrid that is bound to the ClientList collection above and other business objects are bound to other controls.
I would also like to use generics in the controls so that I can move some of the common routines into a base control that the other controls inherit from. What I would like to have is something like this:
CtlDataGrid<T> : CtlBase where T : BaseList<BaseInfo> // a general control that supports all business objects, and
CtlClients : CtlDataGrid<ClientList> // a specific control for clients that is inherited from the above
When I define these controls in this way, I get an error message that says "The type ClientList must be convertible to BaseList<BaseInfo> in order to use it as parameter 'T' in the generic type or method CtlDataGrid".
ClientList is inherited from BaseList<ClientInfo> and ClientInfo is inherited from BaseInfo so I'm surprised that the compiler is not able to convert ClientList into BaseList<BaseInfo>. Do I need to write a custom TypeConverter to accomplish that? I attempted to do that, but it didn't seem to make any difference...
Thanks,
Chuck