Sfdatagrid.MouseClick and Sfdatagrid.MouseDoubleClick event not trigger

hi everyone please help me 


3 Replies 1 reply marked as answer

VS Vijayarasan Sivanandham Syncfusion Team September 28, 2022 01:51 PM UTC

Hi Murad Jafarov,

You cannot handle the Key and Mouse events of the SfDataGrid when raising them, because the TableControl is hosted in the SfDataGrid. So, raise the events for SfDataGrid.TableControl. Please refer to the below code snippet,

//Event subscription

sfDataGrid1.TableControl.MouseClick += OnMouseClick;

sfDataGrid1.TableControl.MouseDoubleClick += OnMouseDoubleClick;

 

//Event customization

private void OnMouseClick(object sender, MouseEventArgs e)

{

    Debug.WriteLine("MouseClick event triggered");

}

 

//Event customization

private void OnMouseDoubleClick(object sender, MouseEventArgs e)

{

    Debug.WriteLine("MouseDoubleClick event triggered");

}


UG Link: https://help.syncfusion.com/windowsforms/datagrid/gettingstarted?cs-save-lang=1&cs-lang=csharp#handling-events

Note: Have to trigger the control events from SfDataGrid.TableControl instead of SfDataGrid 

SfDataGrid contains the CellClick and CellDoubleClick events support. These events raise when the mouse clicks, and the mouse double click in SfDataGrid. Please refer to the below code snippet,

 

 //Event subscription

 sfDataGrid1.CellClick += OnCellClick;

 sfDataGrid1.CellDoubleClick += OnCellDoubleClick;

//Event customization

 private void OnCellDoubleClick(object sender, CellClickEventArgs e)

 {

     Debug.WriteLine("CellDoubleClick event triggered");

 }

 

 //Event customization

 private void OnCellClick(object sender, CellClickEventArgs e)

 {

     Debug.WriteLine("CellClick event triggered");

 }


For more information related to cell click, please refer to the below user guide documentation link,

UG Link: https://help.syncfusion.com/windowsforms/datagrid/selection#getting-the-cell-value-by-using-cell-click-event

Please find the sample in the attachment and let us know if you have any concerns about this.

Regards,
Vijayarasan S

If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.


Attachment: SfDataGridDemo_19b1dbef.zip


MJ Murad Jafarov September 29, 2022 05:25 AM UTC

Thanku you BIG :)



VS Vijayarasan Sivanandham Syncfusion Team September 29, 2022 05:58 AM UTC

Hi Murad Jafarov,

If you are satisfied with our response, please mark it as an answer. Otherwise, please let us know if you have any further queries on this. We are happy to help you😊.

Regards,
Vijayarasan S


Marked as answer
Loader.
Up arrow icon