0

I'm working on a search box to implement in my project, I know that there is no such thing as a search box within the toolbox in VS.

But I came across a question in Microsoft forum, and one of their moderator provided a class (code) that can perform the same functionality as a window search box. This uses a text box with cue controls. But I'm having some problems implementing this, for instance I want to do a search on a listbox that contains a collection of string, what type of code can I implement that would allow me to narrow down the results display on the list box while I'm typing?

Below is a snippet of my code. Leave a comment if any clarification is needed.

private void cueTextBox1_TextChanged(object sender, EventArgs e)
{
    if (cueTextBox1.Text == listBox1.Text)
    {
        listBox1.Text = cueTextBox1.Text;
    }
    else if(cueTextBox1.Text != listBox1.Text)
    {
        listBox1.Text = cueTextBox1.Text;
    }
    else
    {
        listBox1.Items.Clear();
    }
}

private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
    cueTextBox1.Text = listBox1.Text;
}
Grant Winney
  • 65,241
  • 13
  • 115
  • 165
Abner_CV
  • 25
  • 1
  • 2
  • 10

1 Answers1

0

I would suggest you to take a look here. I think this question is similar to what you are looking for.

Community
  • 1
  • 1
Dnyanesh
  • 2,265
  • 3
  • 20
  • 17
  • This isn't really an answer. Once you have earned the requisite reputation, you can flag as duplicate and/or leave the link in comments. – DonBoitnott Apr 22 '14 at 11:17