Datagridview ?

vb.net - vs.2012

I have a DGV with an unbound check box column that I want to set a limit on the amount of ROWS that can be checked within the DGV and during the cellclick event I am calling some code to add the "CHECKED ROWS" up - everything is fine up to this point - However when I reach 10 I want to bring the customer to a halt and UNCHECK the 11th box "THAT IS CHECKED" and not allow further input
checkbox.value = false - everything's but somehow the false setting is returning to a TRUE setting after the cellclick event ?????
MBHEY131Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Use the Cell_Validating event instead, which can be cancelled. You'd have to loop through the rows to determine which have been checked:

Dim cnt As Integer
For each dgr As Datagridviewrow in YourDGV.rows
  If Not IsDBNull(dgr.Cells("Select").Value Then
    If dgr.Cells("Select").Value = True Then
      cnt += 1
      If cnt >10 Then
        Messagebox.Show("You can select only 10 rows")
        e.Cancel = True
        Exit For
    End If
  End If
Next

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MBHEY131Author Commented:
this all worked very well - thanx
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.