tags:

views:

304

answers:

1

Hi:

I want to implement a search box in a window form. In that window form, I have a few botton and a text box. I want to support the use case when user enter a string in the search box and then we can find the that string and highlighted like firefox does. Is it hard to do this?

I googled and found this link that has the search box control. but I don't quite understand the code. If anyone is familiar with control.sendMessage, Could you please give me some help on understand that control.

here is the link: http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/a07c453a-c5dd-40ed-8895-6615cc808d91/

Thanks

+1  A: 

There is no single WinForms or Windows control that provides this functionality. You need to break the problem down into parts:

1) Create a search box

I believe the link you give adds the "Search" cue to a textbox but doesn't add the search button(?) - if that is the case you'll want to combine the textbox with a new button in a user control.

SendMessage sends a message to a Windows control or Window. In this case it tells the textbox to display the "Search" cue. You need to do this because this behaviour is not exposed by the WinForms controls.

2) Work out how to highlight sections of the text

If you are just using the WinForms controls you'll need to use a RichTextBox control and work out how to change the background color at various points in the text.

Matt Breckon
Thanks for the suggestion.
alex