Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / March 2007

Tip: Looking for answers? Try searching our database.

Checkbox value in datagridview

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Eric - 22 Mar 2007 19:12 GMT
I have a datagridview with two columns. That is connected to a bindingsource.

Each column contains a single control, a checkbox.

I want that each time the user checks a checkbox, the checkbox in the other
column in the same row unchecks.

I am amazed I wasn't able to do something so apparently easy. But sometime I
do drown in a glass of water and that seems to be the case now.

I tried handling the CellContentClick event, however I couldn't get the
correct checkboxes values from the datagrid (ie, I check a box and on the
event the checkbox value is false ....).

Could anybody help with this please?
ClayB - 22 Mar 2007 22:48 GMT
Try handling these 2 events.

       void dataGridView1_CellValueChanged(object sender,
DataGridViewCellEventArgs e)
       {
               int otherColumnIndex = (e.ColumnIndex == 1) ? 0 : 1;
               dataGridView1[otherColumnIndex, e.RowIndex].Value = !
Convert.ToBoolean(dataGridView1[e.ColumnIndex, e.RowIndex].Value);
       }

       void dataGridView1_CellMouseUp(object sender,
DataGridViewCellMouseEventArgs e)
       {
           this.dataGridView1.EndEdit();
       }

====================
Clay Burch
Syncfusion, Inc.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.