Your technology certification is waiting. Enroll in Cloud Class ®
private void textBox1_MouseClick(object sender, MouseEventArgs e)
if (textBox1.Text.Length > 0)
//get the position of our click.
int position = textBox1.SelectionStart;
//figure out where the semi colon before this selection is.
string formerText = textBox1.Text.Substring(0, position);
int startPosition = formerText.LastIndexOf(';') + 1;
//figure out where the semi colon after the start of this name block is.
string nameText = textBox1.Text.Substring(startPosition);
int semiColonPosition = nameText.IndexOf(';');
//select the items between the two semicolons.
textBox1.SelectionStart = startPosition;
textBox1.SelectionLength = semiColonPosition;
Open in new window
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.