private void butExamSheet_Click(object sender, EventArgs e) { FormSheetFieldExam FormE = new FormSheetFieldExam(); FormE.ShowDialog(); if (FormE.DialogResult != DialogResult.OK) { return; } if (textSelectionStart < textFieldValue.Text.Length - 1) //if cursor is not at the end of the text in textFieldValue, insert into text beginning at cursor { textFieldValue.Text = textFieldValue.Text.Substring(0, textSelectionStart) + "[" + FormE.ExamFieldSelected + "]" + textFieldValue.Text.Substring(textSelectionStart); } else //otherwise, just tack it on the end { textFieldValue.Text += "[" + FormE.ExamFieldSelected + "]"; } textFieldValue.Select(textSelectionStart + FormE.ExamFieldSelected.Length + 2, 0); textFieldValue.Focus(); }
private void butExamSheet_Click(object sender,EventArgs e) { FormSheetFieldExam FormE=new FormSheetFieldExam(); FormE.ShowDialog(); if(FormE.DialogResult!=DialogResult.OK) { return; } if(textSelectionStart < textFieldValue.Text.Length-1) {//if cursor is not at the end of the text in textFieldValue, insert into text beginning at cursor textFieldValue.Text=textFieldValue.Text.Substring(0,textSelectionStart) +"["+FormE.ExamFieldSelected+"]" +textFieldValue.Text.Substring(textSelectionStart); } else {//otherwise, just tack it on the end textFieldValue.Text+="["+FormE.ExamFieldSelected+"]"; } textFieldValue.Select(textSelectionStart+FormE.ExamFieldSelected.Length+2,0); textFieldValue.Focus(); }