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

DoubleClick Event on Row possible

Hi,

is it possible to create a DoubleClick Event on the Row of a GridDataControl?

Best

5 Replies

AR Akila Rajaram Syncfusion Team June 3, 2014 01:40 PM UTC

Hi Jochen,

 

We have analyzed your query and you can achieve your requirement by using CellClick event,  in that event arguments you can get the ClickCount, based on ClickCount property you can do your action as shown in the below code snippet,

 

public MainWindow()

         {

          InitializeComponent();

            dataGrid.CellClick += dataGrid_CellClick;

           }

 

void dataGrid_CellClick(object sender, GridCellClickEventArgs e)

        {

            if (e.ClickCount==2)

            {

               //code for cell Double click action

            }

}

 

 

Please let us know if you have any queries.

 

Regards,

Akila



JR Jochen Renner June 3, 2014 03:55 PM UTC

Hi Akila,

  1. On the GridDataControl class I have no CellClick Event directly.
    If I goto the model.grid of GridDataControl there is a event called "CellClick"
    dataGrid.Model.Grid.CellClick += Grid_CellClick;
    As I use this it will lead me to the following problem..

  2. I only get these Properties on GridCellEventArgs:

    So there is no Property "ClickCount".

Do I miss something here?


Best



AR Akila Rajaram Syncfusion Team June 4, 2014 10:18 AM UTC

Hi Jochen,

 

Sorry for the inconvenience . We have provide the previous sample in WPF platform and there is no support for ClickCount property in CellGrid event .You can achieve the double click event by using MouseLeftButtonUp event as shown in the below code snippet,

 

public MainPage()

        {

            InitializeComponent();

            columnStylegrid.MouseLeftButtonUp += columnStylegrid_MouseLeftButtonUp;

        }

        DateTime? previousclick;

        void columnStylegrid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)

        {

            if (previousclick != null && DateTime.Now.Subtract((DateTime)previousclick).TotalMilliseconds < 100)

            {

                previousclick = null;

                MessageBox.Show("Double click!");

 

            }

            else

                previousclick = DateTime.Now;

        }

 

 

 

Please let us know if you have any queries.

 

Regards,

Akila



JR Jochen Renner June 4, 2014 03:20 PM UTC

Hi,

with this workaround it would be difficult to choose between single and double click as a double click would always fire the single click too.

Best


AR Akila Rajaram Syncfusion Team June 6, 2014 01:34 PM UTC

Hi Jochen,

 

In the already provided solution, if condition will be true only when you double click the Cell. In the remaining cases, else part will be executed.

 

public MainPage()

        {

            InitializeComponent();

            columnStylegrid.MouseLeftButtonUp += columnStylegrid_MouseLeftButtonUp;

        }

        DateTime? previousclick;

        void columnStylegrid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)

        {

            if (previousclick != null && DateTime.Now.Subtract((DateTime)previousclick).TotalMilliseconds < 100)

            {

                previousclick = null;

                MessageBox.Show("Double click!");

 

            }

            else

                previousclick = DateTime.Now;

        }

 

 

We have achieved the same using helper to fire event only in case of double click. Please find the sample from the below specified location.

 

                                                                                                                                                                                

Please let us know if you have any queries,

 

Regards,

Akila                 

Attachment: DoubleClickDemo_a88aa7ad.zip

Loader.
Live Chat Icon For mobile
Up arrow icon