Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
if user search a word in database then the result will come in gridview or textbox.
now i want to highlight searched text (specific text) into gridview or textbox.
I am using windows Formm.
Posted
Updated 1-Oct-13 5:38am
v2
Comments
Pete O'Hanlon 1-Oct-13 10:23am    
What technology are you using here? ASP.NET? ASP MVC? WinForms? Silverlight? WPF? The answer you get will depend largely on the technology - plus, choose whether it's a textbox or grid view - the solution is different depending on which one.
Muhamad Faizan Khan 1-Oct-13 11:39am    
Windows Form
What have you tried?
Muhamad Faizan Khan 1-Oct-13 11:49am    
nothing no idea about it ! only know how to search a text in Database

1 solution

Hi Muhamed Faizan Khan,

I fear you will have to write some code.

Some hints:

Think about what "highlight" means for you (change ForeColor?)
Use RichTextBox instead of TextBox - better "highlighting" capabillities - how would you do that on a TextBox?

If I guess right, it could be difficult to highlight specific text (parts of a cell) within a GridView - OwnerDrawing is nothing for beginners...

Next question: how to find the texts to highlight in the controls (maybe calcualte a list of start-end indices for all involved controls (text-parts)?

If you got that - just apply your "highlighting" code to all found text-parts.

And of course - Create a "reset" function for easy "un-highlight".

Happy coding!

Kind Regards

Johannes
 
Share this answer
 

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