I cant figure it out why it works this way.
I have two classes which implements interface Pseudo code
Public Interface IChart
{
void Show()
void Hide()
}
public class DailyChart: IChart
{
/***/
public DailyChart(chartControl, Id)
{
chartControl.CustomDraw += new CustomDrawEvent(/**/)
}
}
public class WeeklyChart: IChart
{
public WeeklyChart(chartControl, Id)
{
chartControl.CustomDraw += CustomDrawEvent(/**/)
}
Then in winforms form I declare an object
IChart object
Then I use combobox to switch between charts at a runtime, which goes like
object = new Weeklychart(chartControl, id)
or
object = new DailyChart(chartControl, id)
And then goes the magic I run app, switch from Weekly to Daily, then to Weekly and it causes error. I've debugged application and found out, that CustomDrawEvent is in BOTH classes simultanously - which obviously cause error, because they have different implementations (but, the correct class is called to create chart)
Anyone knows where is the problem?