Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hii again Everyone
i'm beginner,
How to search for specific text in listbox and display it textbox,please.
Posted
Comments
Anuja Pawar Indore 26-Dec-11 7:25am    
Why repost, Improve your question

Dear Hassan,

Apply a foreach loop on the ListBox control like this:-

foreach(String str in lstBox.Items)
{
  if(str.SelectedText=="[Text u want to show in textbox"])
  {
    textBox.Text=str.SelectedText;
  }
}


Mark this as you answer if it helps you out.

Thanks
 
Share this answer
 
Comments
mhassan083 26-Dec-11 7:11am    
thanks dear v.sareen,
but if i need more than word in the same time such as "best regards,signature,...." when i press button any of them display in textbox.
Varun Sareen 27-Dec-11 0:52am    
your welcome dear,

Well I am not getting clear picture where you are facing problem?
you can do in this way:

C#
ListViewItem foundItem =
        textListView.FindItemWithText(searchBox.Text, false, 0, true);
    if (foundItem != null)
    {
        textListView.TopItem = foundItem;

    }


Hope this will help you.
And dont forget to mark as answer if it helps. :)
 
Share this answer
 
Comments
mhassan083 26-Dec-11 7:26am    
thanks dear M.Insan,
But if i need more than word in the same time such as "best regards,signature,...." when i press button any of them display in textbox.

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