public static Button add_Button(this Control control, string text, int top, int left, int height, int width, MethodInvoker onClick) { return control.invokeOnThread( () => { var button = new Button {Text = text}; if (top > -1) button.Top = top; if (left > -1) button.Left = left; if (width == -1 && height == -1) button.AutoSize = true; else { if (width > -1) button.Width = width; if (height > -1) button.Height = height; } button.onClick(onClick); /*if (onClick != null) button.Click += (sender, e) => onClick();*/ control.Controls.Add(button); return button; }); }