)
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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to provide a keyboard shortcut to programmatically open the primitive tab drop down in WinForms TabControlAdv?

Platform: WinForms |
Control: TabControlAdv |
Published Date: April 30, 2011 |
Last Revised Date: February 3, 2020

Keyboard settings

In TabControlAdv, to provide a keyboard shortcut to programmatically open the primitive tab drop down, it is not possible with default drop down. As a work around, we can add ContextMenuStrip and show it when we click the drop down or when we press Ctrl+A.

C#

private void tabControlAdv1_KeyDown(object sender, KeyEventArgs e)
{
   if (e.KeyData == (Keys.Control | Keys.A))
      this.contextMenuStrip1.Show(this.tabControlAdv1, new Point(this.tabControlAdv1.TabPrimitivesHost.Location.X, this.tabControlAdv1.TabPrimitivesHost.Location.Y+10));
}
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
{
   if(this.contextMenuStrip1.Items!=null)
      this.contextMenuStrip1.Items.Clear();
   foreach (TabPageAdv tabpageAdv in this.tabControlAdv1.TabPages)
   {
      this.contextMenuStrip1.Items.Add(tabpageAdv.Text);
   }
}

VB

Private Sub tabControlAdv1_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs) Handles tabControlAdv1.KeyDown
   If e.KeyData = (Keys.Control Or Keys.A) Then
      Me.contextMenuStrip1.Show(Me.tabControlAdv1, New Point(Me.tabControlAdv1.TabPrimitivesHost.Location.X,
Me.tabControlAdv1.TabPrimitivesHost.Location.Y+10))
   End If
End Sub
Private Sub contextMenuStrip1_Opening(ByVal sender As Object, ByVal e As CancelEventArgs) Handles contextMenuStrip1.Opening
   If Me.contextMenuStrip1.Items IsNot Nothing Then
      Me.contextMenuStrip1.Items.Clear()
   End If
   For Each tabpageAdv As TabPageAdv In Me.tabControlAdv1.TabPages
      Me.contextMenuStrip1.Items.Add(tabpageAdv.Text)
   Next tabpageAdv
End Sub

 

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon