private void OperationButtonClick(object sender, EventArgs e) { var s = (sender as Button).Text; var s1 = BOX.Text.Substring(0, BOX.SelectionStart); var s2 = BOX.Text.Substring(BOX.SelectionStart + BOX.SelectionLength, BOX.Text.Length - BOX.SelectionStart - BOX.SelectionLength); BOX.Text = s1 + s + s2; BOX.SelectionStart = s1.Length + s.Length; BOX.SelectionLength = 0; BOX.Focus(); }