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 : Nov 16th 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?

 

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

Article ID: Published Date: Last Revised Date: Platform: Control:
1313 04/30/2011 07/10/2014 WinForms TabControlAdv
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

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