This is a migrated thread and some comments may be shown as answers.

RadPageView Strip mode shortcut for tabs

4 Answers 148 Views
PageView
This is a migrated thread and some comments may be shown as answers.
Patryk
Top achievements
Rank 1
Patryk asked on 13 Apr 2021, 02:09 PM

Hi,

I have a problem. We have migrated from old library to RadPageView and everything is working, except ShortCuts to specific tabs. In previous library we had feature that, we can add & before letter and it has been using as a shortcut to this tab. Also this char has underline under themselves. Is if possible to do it in Telerik? I was looking for it, but without success

Thank you in advice for any answers.

Best regards,

Patryk

4 Answers, 1 is accepted

Sort by
0
Accepted
Nadya | Tech Support Engineer
Telerik team
answered on 14 Apr 2021, 11:21 AM

Hello, Patryk,

In order to achieve this, you should first set the UseMnemonic property to true. Then set the text for the RadPageViewPage with "&" that will draw an underscore under the letter. Then, add the desired shortcut to the Shortcuts collection and perform the desired action. I prepared a sample demonstration for your reference:

public RadForm1()
{
    InitializeComponent();
    this.radPageView1.ViewElement.UseMnemonic = true;
    radPageViewPage1.Item.Text = "&New";
    radPageViewPage1.Item.Shortcuts.Add(new RadShortcut(Keys.Alt, Keys.E));
    radPageViewPage1.Item.Click += this.Item_Click;
}

private void Item_Click(object sender, EventArgs e)
{
    radPageView1.SelectedPage = (sender as RadPageViewItem).Page;
}

I hope this helps. Should you have any other questions do not hesitate to ask. 

Regards,
Nadya
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Patryk
Top achievements
Rank 1
answered on 16 Apr 2021, 02:44 PM

Hi Nadya,

It is very helpful but I have one extra problem. I build it dynamically, 

01.var temp = new RadPageViewPage(itemTitle);
02. 
03.if (itemTitle.Contains("&"))
04.{
05.    var shortcutCharIndex = itemTitle.IndexOf('&') + 1;
06.    var shortcutChar = itemTitle[shortcutCharIndex];
07.    Keys k = (Keys)char.ToUpper(shortcutChar);
08.                 
09.    temp.Item.Shortcuts.Add(new RadShortcut(Keys.Control, k));
10. 
11.}
12.temp.Name = itemKey;
13.tabctlHeader.Pages.Add(temp);

And in line 9 I have NullPointerException, because I don't have an item. What is the proper way to build it?

Thank you in advance

Best regards,

Patryk

0
Nadya | Tech Support Engineer
Telerik team
answered on 19 Apr 2021, 12:57 PM

Hello, Patryk,

You should first add the RadPageViewPage to the RadPageView.Pages collection. Then, add the shortcuts:

var temp = new RadPageViewPage(itemTitle);
radPageView1.Pages.Add(temp);

if (itemTitle.Contains("&"))
{
    var shortcutCharIndex = itemTitle.IndexOf('&') + 1;
    var shortcutChar = itemTitle[shortcutCharIndex];
    Keys k = (Keys)char.ToUpper(shortcutChar);

    temp.Item.Shortcuts.Add(new RadShortcut(Keys.Control, k));

}

I hope this helps. Let me know if you have further questions.

Regards,
Nadya
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Patryk
Top achievements
Rank 1
answered on 19 Apr 2021, 12:59 PM

Hi Nadya,

Thank you very much. It resolved all of my problems :D

Best regards,

Patryk

Tags
PageView
Asked by
Patryk
Top achievements
Rank 1
Answers by
Nadya | Tech Support Engineer
Telerik team
Patryk
Top achievements
Rank 1
Share this question
or