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
close icon

GridDataBoundGrid - catching events in user defined Cell Model

Hi,

I have a UserControl which appears in a series of header cells. This UserControl consists of two CheckBox''s and two ComboBox''s. If I click on a CheckBox/ComboBox in the Cell, the whole cell is temporarily highlighted, and the appropriate event is not kicked off.

I looked at:

Syncfusion\Essential Studio\4.2.0.37\Windows\Grid.Windows\Samples\In Depth\DerivedCellControlTutorial\CS

and a UserCotrnol sample I found on the Forum, but still can''t see how to do this.

I''ve attached the code that I use. Can someone point me in the right direction?

Thanks,

Vito


(In code that adds cell model I do:
_dataGrid.Model.CellModels.Add("OverrideSettings", new OverrideSettingsControlCell(_dataGrid.Model));

and the PrepareViewStyleInfo for the appropriate cells does:

e.Style.CellType = "OverrideSettings";


OverrideSettingsControlCell.zip

3 Replies

AD Administrator Syncfusion Team October 5, 2006 05:48 AM UTC

Hi Vito,

This is the default behavior of the Custom cell type, however to get the desired behavior, please raise the appropriate event using Raisexxxx method and find the below code for calling the CheckBoxClick event

this.Grid.RaiseCheckBoxClick(rowIndex,colIndex,mouseEventArgs);

Please refer the below forum thread for calling the SaveCellInfo event.
http://www.syncfusion.com/support/Forums/message.aspx?MessageID=29181

Let us know if you have any other questions.

Thanks,
Haneef


CH Clive Hill October 5, 2006 12:01 PM UTC

Hi Haneef,

In my custom renderer object (OverrideSettingsControlCellRenderer) I override OnClick to trap when a user clicks on the cell.

If I then call:

this.Grid.RaiseCheckBoxClick(rowIndex,colIndex,mouseEventArgs);

The CheckboxClick is raised for the data grid. This doesn''t help me that much as I still don''t know which Control (CheckBox/ComboBox) within the UserControl was clicked on.

In OverrideSettingsControlCellRenderer I call a method I added called ControlClicked, which takes in the arguments and attempts to find which control was called by working out the X and Y positions (taking into account previous columns and rows above) then calling:

Control childControl = this._mainPanel.GetChildAtPoint(new Point(e.X, e.Y));

to get the Control. The next step I guess would be to attempt to raise the event. I can see how this might work for CheckBox''s but ComboBox''s could be a bit tricky (displaying contents etc).

Is this the path you''d recommend or is there a better way?

Thanks,

Clive


OverrideSettingsControlCell0.zip


AD Administrator Syncfusion Team October 6, 2006 12:37 PM UTC

Hi Vito,

You can use the OverrideSettingsControlCellRenderer.ClikcontrolName property to find the name of the clicked control. Please refer to the attached sample for more details.

activeControl._chbxMarketOnOff.Click +=new EventHandler(controlClick);
activeControl._chbxAutoExec.Click +=new EventHandler(controlClick);

public string ClickcontrolName = string.Empty;

private void controlClick(object sender, EventArgs e)
{
Control c = sender as Control;
ClickcontrolName = c.Name;

if( c is CheckBox )
this.Grid.RaiseCheckBoxClick(this.RowIndex,this.ColIndex, new MouseEventArgs(MouseButtons.Right,1,Cursor.Position.X,Cursor.Position.Y,1 ) );
else
this.Grid.RaiseCellClick(this.RowIndex,this.ColIndex, new MouseEventArgs(MouseButtons.Right,1,Cursor.Position.X,Cursor.Position.Y,1 ) );
}

Sample : http://www.syncfusion.com/Support/user/uploads/UserCellGrid_798f9c08.zip

Let me know if this helps.

Best Regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon