I need a form that inherits from ContextBoundObject intercept able to use certain methods. The problem is that multiple inheritance is not allowed in C #.
public partial class FrmListItems : Form, ContextBoundObject
{
}
Does anyone have any idea?
You can always create a “model” class that inherits a
ContextBoundObjectand implements all desired behavior, than you can use a Data Binding to fill UI elements on the form to show all necessary data on the screen. You can take a look at various patterns like MVx patterns (MVP, MVC, MVVM) to clearly separate you business logic from the UI.Even if C# has a multiple inheritance I’ll suggested to avoid such inheritance because this violates “IS A” relationship between those classes.
You always should think about your design more deeply trying to decrease maintainance costs. Putting in one class UI and business logic always lead to obscure code that would be hard to maintain and evolve.
For example, its hard to me to understand how you are going to test your solution. Using separate class simplifies testability a lot as well.