Right-click the tab on tabcontrol to find the method of the Selected tab.

Source: Internet
Author: User
You can use tabcontrol. selectedtab to read only the tabpage currently in use. The selectindexchanged command can only read the tabpage information of the tab when switching the tabpage tab.
You can click the left button to activate a tabpage, but you cannot right-click it. So how can we design it so that right-clicking can also obtain tabpage information? You can use the following Code :

Private   Void Tabcontrol1_mousedown ( Object Sender, mouseeventargs E)
{
If (E. Button = Mousebuttons. Right)
{
This . Textbox1.text =   "" ;
Point PT =   New Point (E. X, E. y );
Rectangle rectl =   New Rectangle ();
For ( Int I =   0 ; I < Tabcontrol1.tabcount; I ++ )
{
This . Textbox1.text + =   " Widget "   + I +   " : \ R \ n " ;
Rectl = Tabcontrol1.gettabrect (I );
This . Textbox1.text + = Rectl. tostring () +   " \ R \ n " ;
If (Rectl. Contains (PT ))
This . Textbox1.text + = PT. tostring () +   " Belong "   +   " Widget "   + I +   " . "   + Rectl. tostring () +   " \ R \ n " ;
}
}
}

the code mainly obtains the coordinates when right-clicking, obtains the matrix size of each tabpage, and determines whether the right-clicking coordinates are in the Matrix to determine which tabpage is right-clicking.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.