Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MatchCollection/Select Question

Status
Not open for further replies.

euntair

Programmer
Sep 13, 2007
53
US
In the code below, the match collection grabs all of the matching items in a string but the select doesn't hightlight the last one.

if (input.Text.Length > 0) {
Regex r = new Regex(regex.Text);
MatchCollection mc = r.Matches(input.Text);
formatted.Text = mc.Count.ToString();
int count;
for (count = 0; count < mc.Count; ++count) {
input.SelectionBackColor = Color.Yellow;
input.Select(mc[count].Index, mc[count].Length);
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top