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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How do I switch tabPages through accelerator keys and it should switch only when the keys are combined with 'Alt' key?

Platform: WinForms |
Control: TabControlAdv |
Published Date: April 30, 2011 |
Last Revised Date: July 10, 2014

 

You could use KeyDown event to check whether Alt key is pressed and handle TabControlAdv's SelectedIndexChanging event to cancel the switching operation if Alt key is not pressed.

C#

private void tabControlAdv1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)

{

if(e.Alt == false)

{

this.tabControlAdv1.SelectedIndexChanging += new Syncfusion.Windows.Forms.Tools.SelectedIndexChangingEventHandler(tabControlAdv1_SelectedIndexChanging);

}

else if(e.Alt == true)

{

this.tabControlAdv1.SelectedIndexChanging +=new Syncfusion.Windows.Forms.Tools.SelectedIndexChangingEventHandler(tabControlAdv1_SelectedIndexChanging_1);

}

}

private void tabControlAdv1_SelectedIndexChanging(object sender, Syncfusion.Windows.Forms.Tools.SelectedIndexChangingEventArgs args)

{

args.Cancel = true;

}

private void tabControlAdv1_SelectedIndexChanging_1(object sender, Syncfusion.Windows.Forms.Tools.SelectedIndexChangingEventArgs args)

{

args.Cancel = false;

}

VB

Private Sub tabControlAdv1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles tabControlAdv1.KeyDown

If e.Alt = False Then

AddHandler tabControlAdv1.SelectedIndexChanging, AddressOf tabControlAdv1_SelectedIndexChanging

Else If e.Alt = True Then

AddHandler tabControlAdv1.SelectedIndexChanging, AddressOf tabControlAdv1_SelectedIndexChanging_1

End If

End Sub

Private Sub tabControlAdv1_SelectedIndexChanging(ByVal sender As Object, ByVal args As Syncfusion.Windows.Forms.Tools.SelectedIndexChangingEventArgs)

args.Cancel = True

End Sub

Private Sub tabControlAdv1_SelectedIndexChanging_1(ByVal sender As Object, ByVal args As Syncfusion.Windows.Forms.Tools.SelectedIndexChangingEventArgs)

args.Cancel = False

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.

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