Catching Right-Click Event on TabStrip

Posted by: moonlite on 8 September 2017, 1:38 pm EST

  • Posted 8 September 2017, 1:38 pm EST

    Please someone could give any examples on catching right-click event on TabStrip?

    Thanks and regards.

  • Replied 8 September 2017, 1:38 pm EST

    Hello,


    You can use the Spread's MouseDown event and look when the Button parameter is set to 2 to know the right click has happened. You can then use the HitTest property to return a HitTestInfo object to tell you where the click occured.

  • Replied 8 September 2017, 1:38 pm EST

    Thanks, Scott. Then I try this piece of code:

              void fpSpread1_MouseDown(object sender, MouseEventArgs e)
            {
                Rectangle r = fpSpread1.GetRootWorkbook().GetTabStripRectangle();
                FarPoint.Win.Spread.HitTestInformation hti;
                FarPoint.Win.Spread.TabStripHitTestInformation ti;
                hti = fpSpread1.HitTest(r.X, r.Y);
                ti = hti.TabStripInfo;

                if (e.Button == MouseButtons.Right && hti.Type == HitTestType.TabStrip)
                {
                    MessageBox.Show(ti.Button.ToString());
                }
            }

    But
    strange, it cannot catch the tabstrip rectangle. The message box shows
    up whenever I right-click on tabstrip or the sheet. Am I miss something
    here?
  • Replied 8 September 2017, 1:38 pm EST

    Hello,


    You are passing the wrong coordinates to your call to the HitTest method. You are passing the point from the TabStripRec tangle you created instead of the mouse points passed in the event.


    hti = fpSpread1.HitTest(e.X, e.Y);

  • Replied 8 September 2017, 1:38 pm EST

    Thanks, Scott! It works now.
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels