Click here to Skip to main content
15,881,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i Have one textbox if i enter character A then it should show list of data related to character A into Listbox.
Posted
Comments
Manoj Kumar Choubey 15-Sep-12 2:03am    
Hi for windows app / web app ?

Hi Sam, You can use following code:
C#
int index = listBox1.FindString(this.textBox1.Text);
if(0 < index)
{
  listBox1.SelectedIndex = index;
  listBox1.TopIndex = listBox1.SelectedIndices[0];
}


On textBox1_Click event:
C#
textBox1.Select(textBox1.Text.IndexOf(textBox1.text), textBox1.Text.Length);
textBox1.Focus();


Hope it will help you.
 
Share this answer
 
v2
Comments
SamWakchaure 15-Sep-12 2:29am    
i want to retrive entries from database.
Raje_ 15-Sep-12 2:31am    
So what is your problem? Just bind your DataSource with ListBox control.
http://msdn.microsoft.com/en-us/library/w67sdsex.aspx
use DataBindingDource.Filter:

C#
public void textBox1_TextChanged(object sender, EventArgs e)
{
    string filter = string.Format("Column_Name Like '%{0}%'", textBox1.Text.Replcae("'", "''").Replace("[", "[[]");

    // Column_Name iscolumn name of a table that you have bounded to the listBox
    BindingSource.Filter = filter;
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900