Datagridview Check Box

In my DatagridView The last Column Is A checkbox Column.
Since I need only one of the checkboxes to be the main one,i want when i click on it all the others to return in a read only state untill i uncheck it

Please Guide me .
LVL 18
John (Yiannis) ToutountzoglouInstructor Multiengine PilotAsked:
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.

Why not use a RadioButton instead?
John (Yiannis) ToutountzoglouInstructor Multiengine PilotAuthor Commented:
I never thought about it ..let me check it for a while and i msg you back..
thank you for your reply...
John (Yiannis) ToutountzoglouInstructor Multiengine PilotAuthor Commented:
How do i represent a radio button in a datagridview ?...there no choise to change a checkbox column to a radio button column.
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

John (Yiannis) ToutountzoglouInstructor Multiengine PilotAuthor Commented:
i think it a litle trick for me and not for my level...(it is not
How about this..
i need only one check box to be checked
In a total of Rows.Count if >1 checkboxes are checked then message and reject last changes?
This Will Be accomplished by clicking the save button..
I have a code for that is this a good way?
Bob LearnedCommented:
You might be able to do that by attaching to the EditorControlShowing event handler, checking the state of a module-level state flag, and set the CheckBox.Enabled = False for all other CheckBoxes.

Dim CheckboxCount as integer = 0
For i as integer = 0 to grid.Rows.Count - 1
      if CType(grid.Rows(i).Cells("checkboxcolumn").Value, Boolean) = True Then
         CheckboxCount += 1
      end if
If CheckboxCount > 1 then
   'more than one ticks
End If

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
John (Yiannis) ToutountzoglouInstructor Multiengine PilotAuthor Commented:
It is working ...i just add the
If CheckboxCount =0 then....
because always i need one to be checked..
thank you CodeCruiser
John (Yiannis) ToutountzoglouInstructor Multiengine PilotAuthor Commented:
Thanks Also the LearnedOne for his answers
John (Yiannis) ToutountzoglouInstructor Multiengine PilotAuthor Commented:
Code Cruiser ....just a correction....i change the "Value" with "FormattedValue"
That is a good step. You could also use the IsDBNull function to make sure its not null.
John (Yiannis) ToutountzoglouInstructor Multiengine PilotAuthor Commented:
i 've done it both ....and both works properly....
see u in another question...thank you very much
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.