highlight text in datagridview based on search text using vb.net

Recommended Answers

All 9 Replies

DataGridView1.Rows(3).Cells(1).Style.BackColor = Color.Aqua

i want to highlight only the text based on search criteria.. for example my search text is DOT,,,,and on my gridview ihave cell with DOTNET ,,,, so only DOT Should be highlighted

Loop over all rows and cells and set the BG colour for matching cells.

no i dont want the bg color ,,, i want only the particular text say DOT to be highlighted with red color

and i dont want the cell to be highlighted ,,, i want only text to be highlighted

When you highlight text on paper you are changing the background colour. That's the definition of highlighting. That's also the definition in pretty much all the word processor/text display programs I have ever seen. If what you are saying is you want to change the text colour then use ForeColor instead of BackColor in the code I posted above.

Just don't call it highlighting.

ya i agree with u what u said is correct..... but i want to highlight the part of the text in the grid view

Got you. Like selecting "doc" in "indoctrinate" would result in only "doc" being highlighted. I don't think you can get that type of granularity in that control. I might have got that sooner if I'd had more than 3 hours sleep in the last 24 hours.

ya u r right.... thats fine, why dont you just try it... when you are freee....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.