We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Handling checkbox click in GridDataBoundGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

50959 Oct 24,2006 08:46 PM Oct 25,2006 09:33 AM Windows Forms 2
loading
Tags: GridControl
Dan Garvin
Asked On October 24, 2006 08:46 PM

One column of my databound gdbg is a checkbox. This column is a type bit column in the underlying datatable. When the checkbox is clicked, I want to test the value and if true, update a date in another column on the same row. I'm having trouble getting the value of the checkbox. Following is the code for the CheckBoxClick event:

private void gridLabs_CheckBoxClick(object sender, GridCellClickEventArgs e)
{
//Set complete date if Complete is checked
Int32 col1Idx;
Int32 col2Idx;
gridLabs.CurrentCell.MoveTo(e.RowIndex, e.ColIndex, GridSetCurrentCellOptions.SetFocus);
GridCurrentCell cc = gridLabs.CurrentCell;
col1Idx = gridLabs.Binder.NameToColIndex("testComplete");
col2Idx = gridLabs.Binder.NameToColIndex("dateTestCompleted");
if (e.ColIndex == col1Idx)
{
//TestComplete column
if (cc.Renderer.ControlText == "False")
{
//Test is complete
gridLabs[e.RowIndex, col2Idx].CellValue = DateTime.Now.ToShortDateString();
}
else
{
//Test is not complete; clear date
gridLabs[e.RowIndex, col2Idx].CellValue = DBNull.Value;
}
}

}


I'm sure there's a simple solution. Your help is greatly appreciated. Thanks in advance.

Dan Garvin
Replied On October 24, 2006 08:49 PM

Sorry. Forgot to point out that in the click event, I always get the checkbox value prior to clicking it. So, if it is unchecked and I check it, the .cellvalue or the .renderer.controltext give me "false" instead of the expected true. Thanks.

Dan Garvin
Replied On October 25, 2006 09:33 AM

I've opened a case in Direct-Trac. Thanks.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;