Quote Originally Posted by NetMaster
This instance method is a member of a class that is derived from Panel:

Code:
protected Size GetTextExtent(string str)
{
    Size padding = new Size(30,16);
    Graphics gc  = Form.ActiveForm.ActiveMdiChild.CreateGraphics();
    SizeF size   = gc.MeasureString(name, this.Font);
    return size.ToSize() + padding;
}
I would suggest that you pass the Instance of the MDIParent to the class before you use the Creategraphics method on it.