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. Image for the cookie policy date

Getting the record that the cell belongs to when you get a GridTableControlCellClickEvent

Hi,

When a check box in a mult table nested GridGroupingControl changes state I want to take a action. I am trapping the GridTableControlCellClickEvent and need to know which record the event occured on. How can I find that out?

Is this the best way to handle this?

2 Replies

AD Administrator Syncfusion Team March 16, 2007 08:21 PM UTC

Hi Bill,

Is this the best way to handle this?
>>>>>
Yes. You can handle the TableControlCurrentCellChanged event of the grid and get the record and currentcell value using the below code snippet. Please let me know if this helps.

void gridGroupingControl1_TableControlCurrentCellChanged(object sender, GridTableControlEventArgs e)
{
GridCurrentCell cc = e.TableControl.CurrentCell;
GridTableCellStyleInfo style = cc.Renderer.CurrentStyle as GridTableCellStyleInfo;
if (style.CellType == "CheckBox") //GridCellTypeName.CheckBox
{
Element el = style.TableCellIdentity.DisplayElement;

if (el.Kind == DisplayElementKind.Record)
{
GridRecordRow row = el as GridRecordRow;
if (row != null
&& row.ParentRecord != null)
{
Record rec = row.ParentRecord;
if ((bool)cc.Renderer.ControlValue)
{
//Perform True Section....
}
else
{
//Perform False Section....
}
}
}
}
}

Best regards,
Haneef


BL Bill Langlais March 17, 2007 03:44 AM UTC

I am using C++ and here is the code I wrote based on your code:


System::Void
Form1::srgCheckBoxClick(System::Object * sender, Syncfusion::Windows::Forms::Grid::Grouping::GridTableControlCellClickEventArgs * e)
{
bool Value;

GridCellClickEventArgs *Args = e->Inner;
GridCurrentCell *cc = e->TableControl->CurrentCell;
GridTableCellStyleInfo *style = dynamic_cast(cc->Renderer->CurrentStyle);

Element *el = style->TableCellIdentity->DisplayElement;

if (el->Kind == DisplayElementKind::Record) {
GridRecordRow *row = dynamic_cast(el);

if (row != NULL && row->ParentRecord != NULL) {
Record *rec = row->ParentRecord;

Value = Convert::ToBoolean(cc->Renderer->ControlValue);
}
}
}

row is always null when I execute and check or uncheck the check box.

Loader.
Live Chat Icon For mobile
Up arrow icon