private void HandleTableLayoutSizeChanged(object sender, EventArgs e)
{
if (!IsHandleCreated)
CreateHandle();
var scn = Screen.FromControl(this);
int padAbove = tableLayout.Top;
int padBetween = 17; // empirically determined from initial layout in .Designer.cs file
int padBelow = Math.Max(15, ClientSize.Height - cancelBtn.Bottom);
var desiredHeight = padAbove + tableLayout.Height + padBetween + cancelBtn.Height + padBelow +
(Height - ClientSize.Height); // overhead of dialog window
Height = Math.Min(desiredHeight, scn.WorkingArea.Height - 20);
}