Highlight Datagrid Cell based on a string value

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Im trying to get a value in a datagrid to highlight based on the value from a textbox, I cant seem to figure out why its not working right.


<pre> Dim xdata As String = TextBox1.Text
Dim cell As DataGridViewCell
Dim cellVar As String[/code]
<pre>
For Each row As DataGridViewRow In Me.Tbl_NameDataGridView.Rows
cell = row.Cells(0)
cellVar = row.Cells(0).Value
If cellVar.Contains(xdata) Then
cell.Style.BackColor = Color.Red
End If
Next[/code]
<br/>
<br/>
<hr class="sig I will be legendary someday, just not today.

View the full article
 
Back
Top