Causes a NRE on the Console.WriteLine line, because OnLayout is getting called in the base constructor before MyControl's constructor gets a chance to run.
using System;
using System.Windows.Forms;
using System.Collections;
class TestForm : Form
{
static void Main ()
{
Application.Run (new TestForm ());
}
public TestForm ()
{
MyControl mc = new MyControl ();
}
private class MyControl : ScrollableControl
{
private ArrayList al;
public MyControl ()
{
al = new ArrayList ();
}
protected override void OnLayout(LayoutEventArgs levent)
{
Console.WriteLine (al.Count);
base.OnLayout(levent);
}
}
}