|
-
Dec 30th, 2014, 10:36 AM
#1
Thread Starter
Junior Member
Increment cell data on search
I have a datagridview on which I perform a search (for a keyword). The rows in which the keyword exists are highlighted and a checkbox in a DGV column is checked. What I need to do is is to add a reference to each of the highlighted rows in Col2 which is based on a user entered format and incremented by 1. For example, the format might be "PRG_CR123_x" where x is the incremented number. I'm sort of succeeding BUT what I actually get is the row number NOT the row number of the search. In the screenshot you can see that the first row in the search is row 18 but the 'TC' col needs to show "PRG_1" and so on.
Here's my code so far.
Thanks
David
Private Sub cmdSearch_Click(sender As System.Object, e As System.EventArgs) Handles cmdSearch.Click
Dim i As Integer = 0
Dim Inc As String = txtCurFormat.Text
For Each row As DataGridViewRow In DataGridView1.Rows
Dim KeyWord As String = row.Cells(1).Value.ToString
If KeyWord.Contains("Then") Then
'row.DefaultCellStyle.BackColor = Color.Red
row.Selected = True
row.Cells(3).Value = True
row.Cells(2).Value = inc & i
End If
i = i + 1
Next
End Sub
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|