السلام عليكم ورحمة الله وبركاته
الرجاء المساعده في كيفية تحديد ( تظليل ) الاسماء المكرره في عمود الاسماء في الداتا قريد فيو
للعلم استخدمت الكود في الاسفل ولم تنفع الطريقه
يرجى المساعده
الرجاء المساعده في كيفية تحديد ( تظليل ) الاسماء المكرره في عمود الاسماء في الداتا قريد فيو
للعلم استخدمت الكود في الاسفل ولم تنفع الطريقه
يرجى المساعده
كود :
Sub HighlightDupes(ByRef dgv As DataGridView, ByVal col_id As Integer)
Dim dgvCol As DataGridViewColumn = DataGridView1.Columns("colname")
dgv.Sort(dgvCol, System.ComponentModel.ListSortDirection.Ascending)
Dim numRows As Integer = dgv.Rows.Count() ''// or dgv.SelectedRows.Count() for the selected rows
Dim flagFirstRow As Boolean = True
Dim tempStr As String = ""
For Each RW As DataGridViewRow In dgv.Rows ''// or dgv.SelectedRows for the selected rows
On Error Resume Next
If Not (flagFirstRow) Then
If (RW.Cells("colname").Value.ToString() = tempStr) Then
''// RW.Cells(col_id).Style.BackColor = Color.LightGreen
''// RW.Cells(col_id).Style.BackColor = Color.White
RW.Cells("colname").Selected = True
dgv.CurrentCell.Style.BackColor = Color.LightGreen
dgv.CurrentCell.Style.ForeColor = Color.White
' MsgBox("Dupe found: " & tempStr)
End If
End If
tempStr = RW.Cells("colname").Value.ToString()
flagFirstRow = False
Next
End Sub