public static void SetCaretPosition(TextBoxBase textBox, int position) { if (textBox.InvokeRequired) { textBox.Invoke(new setCaretPosition(SetCaretPosition), textBox, position); } else { textBox.SelectionStart = position; } }