Quantcast
Channel: Active questions tagged row - Stack Overflow
Viewing all articles
Browse latest Browse all 448

How to return Cell Reference of DataGridView if Value in that Cell Matches with Textbox?

$
0
0

I would like to get the reference to a Cell - i.e. the row and column numbers, or the cell address of the particular cell if that DataGridView cell contains the value of a Textbox.

I've explored many URLs to get what I desire. I even might have missed visiting the URLS as may be asked in a different manner.

Dim colNdx As IntegerDim rowNdx As IntegerDim IsFound As Boolean = FalseFor Each rw As DataGridViewRow In DataGridView1.Rows    For i As Integer = 0 To DataGridView1.Columns.Count - 1        If rw.Cells(i).Value.ToString = TextBox1.Text Then            IsFound = True            Exit For        End If    NextNextIf (IsFound) Then    MessageBox.Show("Data Exists! in Cell of DataGridWiew1" & )    DataGridView1.Rows(rowNdx).Cells(colNdx).ValueElse    MessageBox.Show("Data Not Exists!")End If

So How can I have the cell reference of rw.Cells(i).Value.ToString(), for example, displaying the row and column numbers of that cell which exists in the DataGridView and is matched with the Textbox?

I tried the above code but could not set it properly to get the cell reference.


Viewing all articles
Browse latest Browse all 448

Trending Articles