How to use mnemonic to access Pageviewpage

6 posts, 1 answers
  1. Roberto Wenzel
    Roberto Wenzel avatar
    41 posts
    Member since:
    Sep 2012

    Posted 15 Dec 2010 Link to this post

    Hello,
    I would like to access the Tabs in my Pageview control with the keyboard.
    I am used to type e.g. "&Tabpage" with the ampersand for the PageViewPage text attribute, so that the T is underlined and I can use the ALT + T keys to activate that Pageviewpage.
    Unfortunately this does not work. I always have "&Tabpage" as visible text.
    Which settings do I have to make to activate the UseMnemonic feature. I tried several but with no success.
    Could someone please help me.
    Thanks in advance.
    Cheers Roberto
  2. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 15 Dec 2010 Link to this post

    Hello,
    I've tried this in the latest version, but also could not get mnemonics to work as expected. The code I tried is as follows:
    Me.RadPageView1.ViewMode = PageViewMode.Strip
    Me.RadPageView1.ViewElement.UseMnemonic = True
    Me.RadPageViewPage1.Item.UseMnemonic = True
    Me.RadPageViewPage2.Item.UseMnemonic = True
    Me.RadPageViewPage3.Item.UseMnemonic = True
    Me.RadPageViewPage1.Text = "&First"
    Me.RadPageViewPage2.Text = "&Second"
    Me.RadPageViewPage3.Text = "&Third"

    However, as of Q2 2010 Telerik have introduced a new shortcut mechanism (RadShortcut) which introduces many improvements. It also supports the so called "Global Shortcuts" which might help in your case. More information can be found at this link

    Hope that helps
    Richard
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Roberto Wenzel
    Roberto Wenzel avatar
    41 posts
    Member since:
    Sep 2012

    Posted 16 Dec 2010 Link to this post

    Thank you Richard for your hint.
    Unfortunately I could not get this to work, but I have a workaround for this issue:
    Example for Visual Basic

    1. Use the following structure for your RadPageViewPage.Text value
    <html><u>U</u>ser</html>
    where the "U" of the word "User" is underlined.

    2. Set the KeyPreview feature of your form to "true" to validate keyboard strokes.

    3. Add the following code to the KeyDown event of your form
    E.g. to capture the "ALT+U" key event and select a PageViewPage called "User":

    If e.Alt And e.KeyCode.ToString = "U" Then
                e.SuppressKeyPress = True
                Dim pv_user As RadPageViewPage = Me.rpvp_User
                Me.rpvw_Settings.SelectedPage = pv_user
            End If

    The code line " e.SuppressKeyPress = True " suppresses the Beeping

    Hope that might help somebody.
    Cheers Roberto


  5. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 16 Dec 2010 Link to this post

    Hi Roberto,

    I'm glad that you found a workaround. Perhaps this will be on the ToDo list for a future release or service pack.
    All the best
    Richard
  6. Answer
    Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 20 Dec 2010 Link to this post

    Hello Roberto,

    There is an easier way of achieving this. First of all, it is enough to set the UseMnemonics and ShowKeyboardCues properties to True and then you can set the underlined letter by an ampersand before it:
    RadPageViewPage1.Item.Text = "N&ew"
    RadPageViewPage1.Item.UseMnemonic = True
    RadPageViewPage1.Item.ShowKeyboardCues = True

    This will make the 'e' letter underlined, but the item will not react to any keyboard input. You can fix this by using our shortcuts mechanism. Please refer to the following code:
    RadPageViewPage1.Item.Shortcuts.Add(New RadShortcut(Keys.Alt, Keys.E))
    AddHandler RadPageViewPage1.Item.Click, AddressOf Item_Click

    We add a shortcut to the item and subscribe to its click event because when the shortcut is executed, the click event of the item is fired (but the pages are selected on the MouseDown event which is not fired). So we handle the click event of the item and select its corresponding page. Please refer to the following snippet:
    Private Sub Item_Click(sender As Object, e As EventArgs)
        RadPageView1.SelectedPage = TryCast(sender, RadPageViewItem).Page
    End Sub

    Another approach is to implement your own custom shortcut provider. You can find more information about shortcuts on the link that Richard posted.

    I hope this was helpful. Should you have any further questions, do not hesitate to ask.

    Greetings,
    Ivan Todorov
    the Telerik team
    Check out the Q1 2011 Roadmap for Telerik Controls for Windows Forms.
  7. Roberto Wenzel
    Roberto Wenzel avatar
    41 posts
    Member since:
    Sep 2012

    Posted 21 Dec 2010 Link to this post

    Hello Ivan,
    thank you very much for your solution. Its perfect and hels a lot.
    Cheers Roberto
Back to Top
UI for WinForms is Visual Studio 2017 Ready