---
title: "How to Highlight Cell in a grid which matches search result?"  
description: "How to Highlight Cell in a grid which matches search result?"  
author: "Anonymous User"  
published: 2014-10-21  
updated: 2014-11-06  
canonical: https://www.mindstick.com/forum/2431/how-to-highlight-cell-in-a-grid-which-matches-search-result  
category: "asp.net"  
tags: ["asp.net", "grid"]  
reading_time: 2 minutes  

---

# How to Highlight Cell in a grid which matches search result?

```
Dim DataGridView1 = New DataGridView      'add columns to DGV      DataGridView1.Columns.Add("Year", "Year")      DataGridView1.Columns.Add("Make", "Make")      DataGridView1.Columns.Add("Model", "Model")      DataGridView1.Columns("Year").AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill      DataGridView1.Columns("Make").AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill      DataGridView1.Columns("Model").AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill      DataGridView1.RowHeadersVisible = False       'add items to DGV      DataGridView1.Rows.Add("2010", "Chevrolet", "Camaro")      DataGridView1.Rows.Add("2006", "Ford", "Mustang")      DataGridView1.Rows.Add("2008", "Dodge", "Charger")      DataGridView1.Rows.Add("2007", "Chevrolet", "Corvette")In this Datagridview if i type "ro" in a text box i need any column that having "ro" (eg: Chevrolet,Camaro ) should be highlight. 
```

## Replies

### Reply by Horas Panjaitan

hi Pravesh Singh\

how to filter records gridview dropdownlist using mysql database

what if it does not use SqlDataSource.\
I populate and retrieve data from code behind\
please help me

\

### Reply by Anonymous User

```
for (int i = 0; i < dataGridView1.Rows.Count; i++)                {                    if (dataGridView1.Rows[i].Cells["Make"].Value.ToString().ToUpper().Contains("ro"))                    {                        dataGridView1.Rows[i].Cells["Make"].Style = new DataGridViewCellStyle() { Font = new Font(dataGridView1.Font, FontStyle.Bold), ForeColor = Color.DodgerBlue };//it will change cell forecolor you can use according to you required action// same like forecolor you can change backcolor or cell and also row.                    }//ro // or you can use textbox value.                    if (dataGridView1.Rows[i].Cells["Model"].Value.ToString().ToUpper().Contains(txtBox1.Text))                    {                        dataGridView1.Rows[i].Cells["Model"].Style = new DataGridViewCellStyle() { Font = new Font(dataGridView1.Font, FontStyle.Bold), ForeColor = Color.DodgerBlue }; // for full row colors you can use following// dataGridView1.Rows[i].DefaultCellStyle = new DataGridViewCellStyle() { Font = new Font(dataGridView1.Font, FontStyle.Bold), ForeColor = Color.DodgerBlue, BackColor = Color.Green };                    }                   		}
```


---

Original Source: https://www.mindstick.com/forum/2431/how-to-highlight-cell-in-a-grid-which-matches-search-result

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
