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

SfDataGrid right click at StackedHeaderRow

I am having an SfDataGrid with StackedColumnRow and I want to add an event that will be fired when I press right click only on StackedColumnRow in order to open a new config window. 

Does the SfDataGrid have a spesific event for this or is there a work around to achieve this goal?

Thank you

1 Reply

JS Jayapradha S Syncfusion Team March 6, 2015 12:14 PM UTC

Hi Constantin,

Thank you for using Syncfusion products.

We have analyzed your requirement and you can open a new window when right click on a stacked column by using MouseRightButtonDown event and shown in the below code snippet,

Code Snippet:

VisualContainer visualContainer;

        void dataGrid_MouseRightButtonDown(object sender, MouseButtonEventArgs e)

        {

            var point = e.GetPosition(this.dataGrid);

            var propertyInfo = dataGrid.GetType().GetProperty("VisualContainer", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);

            visualContainer = propertyInfo.GetValue(dataGrid) as VisualContainer;

            var rowColumnIndex = visualContainer.PointToCellRowColumnIndex(point);

            var headerRowIndex = dataGrid.GetHeaderIndex();

            if (rowColumnIndex.RowIndex < headerRowIndex)

            {

                Window newWindow = new Window();

                newWindow.ShowDialog();

            }

        }

We have prepared a sample to achieve your requirement and please find the sample from the below location,

Sample Link: StackedHeader.zip

Kindly let us know if you require any further assistance on this.

Regards,

Jayapradha



Loader.
Up arrow icon