Home > DeveloperSection > Forums > How to get single click event on image in column of DevExpress Grid Control using wpf?
jacob rasel
jacob rasel

Total Post:88

Points:616
Posted on    September-03-2013 9:06 AM

 WPF WPF 
Ratings:


 1 Reply(s)
 3710  View(s)
Rate this:

I have Navigation bar control and one NavBar Group contains the grid control. I want to get the single click event on particular image which is in one column of grid control and on image click event I have to show the pop-up for some menu options.

I’m using the grid control’s preview mouse left button up event to get the click but it’s not working because the grid control resides in Navbar control.

Basically my problem is that I am not able to get the single click on image which is on column of grid control and grid column itself resides in one Navbar group of NavBar Control.

This link has my demo project.

Any help will be appreciated.



Sumit Kesarwani

Total Post:378

Points:2694
Posted on    September-03-2013 9:16 AM

Hi Jacob,

The below code will solve your problem:-

private void gridControl1_PreviewMouseDown(object sender, MouseButtonEventArgs e) {

TableViewHitInfo hit = tableView1.CalcHitInfo(e.OriginalSource as DependencyObject);

if (hit.InRowCell) {

 gridControl1.View.FocusedRowHandle = hit.RowHandle;

   if (e.ClickCount == 1)

    { 

      if (e.XButton1 == MouseButtonState.Released)

        {

           if (hit.Column.FieldName == "number")

               {

                      var row = gridControl1.GetFocusedRow();

                      data d = (data)row;

                      MessageBox.Show(d.number.ToString());

                      x = d.number;

                    }

                    if (e.RightButton == MouseButtonState.Pressed)

                    {

                        if (hit.Column.FieldName == "image")

                        {

                            gridControl1.View.FocusedRowHandle = hit.RowHandle;

                            var row = gridControl1.GetFocusedRow();

                            data d = (data)row;

                            x = d.number;

                            popup.StaysOpen = true;

                            popup.IsEnabled = true;

                            popup.IsOpen = true;

                        }

                    }

                }

}

}


Don't want to miss updates? Please click the below button!

Follow MindStick