Search code examples
c#winformsdevexpressxtragrid

Click on Groupcaption in LayoutView


i have an Xtragrid, where iam using a Layoutview. In my card i got two Groups with some content in it (no grouprow!). Is it possible to fire an click event, if the user click on the groupcaption?

It is a normal group! For Example select 3 textedits and then rightclick->group in the designer. The same you can do inside your cards of a layoutview.

regards.


Solution

  • You can use the View's MouseDown event handler and use HitTests to see if it's a Layout Item, then test the layout item to see if it's a group and check it's Border Info to get the caption bounds.

           LayoutView View = (sender as LayoutView);
            var hi = View.CalcHitInfo(e.Location);
            if (hi.HitTest == LayoutViewHitTest.LayoutItem && hi.LayoutItem is DevExpress.XtraLayout.LayoutControlGroup)
            {
                var Border = (hi.LayoutItem.ViewInfo.BorderInfo as DevExpress.Utils.Drawing.GroupObjectInfoArgs);
                if (Border.CaptionBounds.Contains(e.Location))
                {
                    MessageBox.Show("Hit Group: " + Border.Caption);
                    return;
                }
            }
            MessageBox.Show("Missed!");