I need to modify some data bindings dynamically. So I had planned to perform the operation during/after the initialisation of the control in its parent.
But despite the msdn page on Control.OnLoad Method, my class refuses to compile:
Error 810 ‘Views.Test.OnLoad(System.EventArgs)’: no suitable method found to override
My code:
class Test : Control
{
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (true)
{
System.Diagnostics.Debug.Assert(false);
}
}
}
Any idea about what I am doing wrong ?
Edit: @Roken has noticed that I was mismatching with the System.Web.UI.Control because my class derives from System.Windows.Controls.Control
So my question becomes: When and how should I perform my modifications on the binding of this control ? What method to override, or what event to subscribe to?
Is this a Windows Forms control or a Web control? The link you provided is for the web control; the WinForms Control does not contain OnLoad(). OnCreateControl() might be of use to you for WinForms, or OnInitialized() for WPF.