public void SetBackColor(Color col) { if (this.InvokeRequired) { SetBackColorCallback d = new SetBackColorCallback(SetBackColor); this.Invoke(d, new object[] { col }); } else { this.BackColor = col; } }
public static void SetBackColor(Form form, Control ctrl, Color color) { if (form == null) { return; } if (ctrl == null) { return; } if (ctrl.InvokeRequired) { var d = new SetBackColorCallback(SetBackColor); form.Invoke(d, new object[] { form, ctrl, color }); } else { ctrl.BackColor = color; } }