Experts Exchange connects you with the people and services you need so you can get back to work.
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.
Premium members get this course for $349.00.
Premium members get this course for $31.25.
Premium members get this course for $108.00.
Premium members get this course for $389.00.
Premium members get this course for $37.50.
Premium members get this course for $79.20.