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

Date and Calculator with alternate hotkey

2 Answers 40 Views
GridView
This is a migrated thread and some comments may be shown as answers.
A-Telerik-User
Top achievements
Rank 1
A-Telerik-User asked on 19 Jul 2019, 08:36 AM

Good day,

The little calendar could be activated/popup with hotkey F4 for GridViewDatetimeColumn and the calculator for GridViewCalculatorColumn. Is this hotkey changeable, said change to F2 to bring up these?

2 Answers, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 23 Jul 2019, 11:03 AM
Hello,  

Indeed, by default, pressing F4 while RadCalculatorEditor is active, will show the popup calendar. In order to prevent this when pressing F4 and execute the same logic after F2 is pressed, you can refer to the following code snippet:

public RadForm1()
{
    InitializeComponent();
 
    GridViewCalculatorColumn column = new GridViewCalculatorColumn("Calculator column");
    this.radGridView1.Columns.Add(column);
 
    this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
 
    this.radGridView1.Rows.Add(3.14159);
    this.radGridView1.Rows.Add(2.71828);
    this.radGridView1.Rows.Add(1.41421);
    this.radGridView1.Rows.Add(0.57721);
    this.radGridView1.Rows.Add(4.66920);
    this.radGridView1.Rows.Add(3.27582);
    this.radGridView1.Rows.Add(0.56714);
 
    this.radGridView1.CellEditorInitialized += radGridView1_CellEditorInitialized;
}
 
private void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
{
    RadCalculatorEditor calcEditor = e.ActiveEditor as RadCalculatorEditor;
    if (calcEditor != null)
    {
        RadCalculatorEditorElement el = calcEditor.EditorElement as RadCalculatorEditorElement;
 
        el.EditorContentElement.TextBoxItem.PreviewKeyDown -= TextBoxItem_PreviewKeyDown;
        el.EditorContentElement.TextBoxItem.PreviewKeyDown += TextBoxItem_PreviewKeyDown;
         
        el.PopupOpening -= el_PopupOpening;
        el.PopupOpening += el_PopupOpening;
    }
}
 
private void el_PopupOpening(object sender, CancelEventArgs e)
{
    e.Cancel = cancel;
    cancel = false;
}
 
bool cancel = false;
 
private void TextBoxItem_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
    if (e.KeyData == Keys.F4)
    {
        cancel = true;
    }
    else if (e.KeyData == Keys.F2)
    {
        RadCalculatorEditor calcEditor = this.radGridView1.ActiveEditor as RadCalculatorEditor;
        RadCalculatorEditorElement el = calcEditor.EditorElement as RadCalculatorEditorElement;
        el.ShowPopup();
    }
}

Feel free to use a similar approach for the date time column as well.
 
I hope this information helps.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
A-Telerik-User
Top achievements
Rank 1
answered on 24 Jul 2019, 01:49 AM

Thanks for the solution. 

Beside i have found an alternative with the RadShortcut which i could apply to columns' calculator and calendar popup.

Tags
GridView
Asked by
A-Telerik-User
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
A-Telerik-User
Top achievements
Rank 1
Share this question
or