Click here to Skip to main content
Click here to Skip to main content

DataGridView CheckBoxes and Context Menu

By , 7 May 2013
 

Introduction

I recently had problems getting a checkbox state updated in time for a right click menu. The check box state is not available when a cell is in edit mode. A quick solution was to get the cell out of edit mode before the menu click events. I used the .cellcontentclick event; when the cell clicked was the check box, I moved over one cell. This has the action of leaving the edit mode on the cell of the checkbox. The column of the checkbox is 0 in the example.

dclconst CbSel_col value(00)
BegSr DataGridView1_CellContentClick Access(*Private) Event(*this.DataGridView1.CellContentClick)
DclSrParm sender Type(*Object)
DclSrParm e Type(System.Windows.Forms.DataGridViewCellEventArgs)
if e.ColumnIndex = CbSel_col
   DataGridView1.CurrentCell = DataGridView1(1+e.ColumnIndex,e.RowIndex) 
endif
EndSr

License

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

About the Author

Weberto.com
Software Developer
United States United States
Member
Writing code for 00100010 years.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130513.1 | Last Updated 7 May 2013
Article Copyright 2013 by Weberto.com
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid