Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to check the cell if contains a value or has a how many strings in a cell

sample

id head
1 11

if head column has less than or equal to 1 string then

else

end if

What I have tried:

Dim columnName As String = dgvResults.Columns(e.ColumnIndex).Name
Dim cellVal As String = e.FormattedValue.ToString()
If e.ColumnIndex = 0 AndAlso cellVal.Length <> 5 Then
    e.Cancel = True
    MessageBox.Show(columnName & " must be 5 Digits Long!")
End If
Posted
Updated 16-May-22 21:50pm

1 solution

The Head column won't have index 0 - you have an ID column in front of it, so it's index would be 1.

So your If test assumes they are changing the ID column, not the Head.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900