Phil5780
asked on
DataGridView Checkbox value
I have a winForm application that contains a DataGridView. The grid contains several columns, one of which is a checkbox column. I'm able to target the column but the boolean value is always true no matter the actual state on screen. Why does the checkbox show "true" when it's clearly unchecked? This same type of code works fine for the other text cells.
private void UpdateAdminMemberRecord(DataGridViewCellEventArgs e)
{
//Instantiate objects
String strNewValue = "";
String strColumnName = "";
Int32 intTeamMemberID = 0;
Boolean blnIsActive = false;
OleDbCommand cmdUpdateMembers = new OleDbCommand();
Tools objTools = new Tools();
switch (grdAdminMembers.Columns[e.ColumnIndex].HeaderText)
{
case "FirstName":
strNewValue = (String)grdAdminMembers.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
break;
case "LastName":
strNewValue = (String)grdAdminMembers.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
break;
case "Username":
strNewValue = (String)grdAdminMembers.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
break;
case "Password":
strNewValue = (String)grdAdminMembers.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
break;
case "IsActive":
blnIsActive = (Boolean)grdAdminMembers.Rows[e.RowIndex].Cells["IsActive"].Value;
if (blnIsActive == true) { strNewValue = "1"; }
else { strNewValue = "0"; }
break;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
http://www.tek-tips.com/viewthread.cfm?qid=1613656&page=8
CheckBox in DataGridView | Free source code, tutorials and articles
http://www.sourcecodester.com/visual-basic-net/checkbox-datagridview.html
http://www.tek-tips.com/viewthread.cfm?qid=1613656&page=8
CheckBox in DataGridView | Free source code, tutorials and articles
http://www.sourcecodester.com/visual-basic-net/checkbox-datagridview.html
Open in new window
Reference: http://forums.devx.com/showthread.php?t=163391