I am creating a program in C# and I allow the users to type in to a text box and it searches within a datagridview for the rows matching the search. Now though they want to be able to search Dr and it should find any records that have the letters dr consecutively and with no other abc letters in between but it can have a space, or a period, or a comma... for example
D.R., Dr., D R, D-R-, D,R,,
Currently this is how the search works:
private void FilterByPanel(string text1, string text2)
{
string txt1 = Validation.EscapeLikeValue(txtID.Text);
string txt2 = Validation.EscapeLikeValue(txtName.Text);
StringBuilder sb = new StringBuilder();
if (txtID.Text.Length > 0)
{
sb.Append(text1 + " like '" + txt1 + "%'");
}
if (txtName.Text.Length > 0)
{
if (sb.Length > 0)
{
sb.Append(" and ");
}
sb.Append(text2 + " like '" + txt2 + "%'");
}
if (dt.DefaultView.Count > 0)
{
bs.Position = 0;
}
bs.Filter = sb.ToString();
DataGridViewBinding.DataGridViewEntryCount(dgvList, lblEntryCount);
}
Debra has a question