Hi,
Looking for suggestions of a how you could hotkey the copy the selected line in the sales order summary and paste in one hit.
There doesn’t appear to be a hot key assignment for copy selected and paste insert.
Hi,
Looking for suggestions of a how you could hotkey the copy the selected line in the sales order summary and paste in one hit.
There doesn’t appear to be a hot key assignment for copy selected and paste insert.
I know you can set a Hotkey Programmatically
baseToolbarsManager.Tools["RefreshTool"].SharedProps.Shortcut = (Shortcut)Shortcut.ShiftF9;
I wonder if you get the GUID to the Grid and then debug the Grid and look for the Context Menu Strip, if you can find the keys…
It should have a list of the following Keys:
Then set a HotKey, probably in the Form_Load Event on the Grids ContextMenuPopup, obviously on something more friendly like CTRL+SHIFT+C or CTRL+SHIFT+I
// In Theory.... Haven't checked which var it sets ContextMenu on
EpiUltraGrid grdList = ((EpiUltraGrid)csm.GetNativeControlReference("87f88dc8-1b94-4324-ba83-583a2af5cbb9"));
// var something = grdList.Grid.ContextMenu;
ContextMenuPopup.Tools["EpiGridPasteInsert"].SharedProps.Shortcut = (Shortcut)Shortcut.ShiftF9;
Came up with this. Add a new toolbar button in the actions menu. Then assign the shortcut. and use the OnGridCopySelection and the OnGridPasteInsert methods to do the copy paste.
// **************************************************
// Custom code for POEntryForm
// Created: 16/06/2019 2:27:59 PM
// **************************************************
extern alias Erp_Contracts_BO_Vendor;
extern alias Erp_Contracts_BO_Company;
extern alias Erp_Contracts_BO_Part;
extern alias Erp_Contracts_BO_VendorPPSearch;
extern alias Erp_Contracts_BO_VendCntSearch;
extern alias Erp_Contracts_BO_PO;
extern alias Erp_Contracts_BO_MiscShip;
extern alias Erp_Contracts_BO_Receipt;
extern alias Erp_Contracts_BO_Plant;
extern alias Erp_Contracts_BO_JobEntry;
extern alias Erp_Contracts_BO_JobMtlSearch;
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Erp.Adapters;
using Erp.UI;
using Ice.Adapters;
using Ice.Lib;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;
//Added for customisation
using System.Collections.Generic;
using System.Reflection;
using Infragistics.Win.UltraWinToolbars;
public partial class Script {
// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
// Begin Wizard Added Module Level Variables **
// End Wizard Added Module Level Variables **
// Add Custom Module Level Variables Here **
public void InitializeCustomCode () {
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
// Begin Wizard Added Variable Initialization
// End Wizard Added Variable Initialization
// Begin Wizard Added Custom Method Calls
var objMenu = POEntryForm.GetType ().InvokeMember ("baseToolbarsManager", BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic, null, POEntryForm, null);
var tools = (UltraToolbarsManager) objMenu;
ButtonTool buttonTool1 = new ButtonTool ("CopyPOLine");
tools.Tools.Add (buttonTool1);
PopupMenuTool pop = (PopupMenuTool) tools.Tools["ActionsMenu"]; //this is the pop up menu for the Actions menu item
pop.Tools.AddTool ("CopyPOLine");
pop.Tools["CopyPOLine"].SharedProps.Caption = "Copy PO Line";
pop.Tools["CopyPOLine"].SharedProps.AppearancesLarge.Appearance.Image = EpiUIImages.GetImage ("Copy");
pop.Tools["CopyPOLine"].SharedProps.AppearancesSmall.Appearance.Image = EpiUIImages.GetImage ("Copy");
pop.Tools["CopyPOLine"].ToolClick += CopySelectedPORelLine;
pop.Tools["CopyPOLine"].SharedProps.Shortcut = (Shortcut) Shortcut.F12;
// End Wizard Added Custom Method Calls
}
public void DestroyCustomCode () {
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
// Begin Wizard Added Object Disposal
// End Wizard Added Object Disposal
// Begin Custom Code Disposal
// End Custom Code Disposal
}
private void CopySelectedPORelLine (Object sender, ToolClickEventArgs e)
{
//Test to see if there are any selected lines on the POLineRel grid first
EpiUltraGrid POLinesGrid = (EpiUltraGrid) csm.GetNativeControlReference ("619b890f-7d96-4dbe-9309-fd59da524a6a");
if (POLinesGrid.Selected.Rows.Count < 1 || POLinesGrid.Selected.Rows.Count > 1) {
POLinesGrid = null;
MessageBox.Show ("You can only select one PO Line at a time to copy. " + Environment.NewLine + "Please select one line on the grid and then try again.");
return;
}
try {
POLinesGrid.OnGridCopySelection (false);
POLinesGrid.OnGridPasteInsert ();
}
catch (System.Exception ex)
{
ExceptionBox.Show (ex);
}
}
}
Should be translatable to any grid.
Thanks for pointing me in the right direction @hkeric.wci
I wanted to use Ctrl+Numpad0, but that is not an available shortcut combination. You could go to all the effort to capture the keystrokes, based on reading I have done, but I just wanted to keep things as simple as possible.
Updated version to select the row first automagically
// **************************************************
// Custom code for SalesOrderForm
// Created: 16/06/2019 9:38:31 PM
// **************************************************
// Created By: SHALL
// Date: 16/06/2019
// Purpose: Demonstrate Copying a SO Line with a shortcut key.
// Update 09/07/2019: SH: Change Menu to read "Duplicate SO Line"
// Update 09/07/2019: SH: Automatically select the active row.
// Update 09/07/2019: SH: Test for multiple lines being already selected and prompt the duplicate.
extern alias Erp_Contracts_BO_AlternatePart;
extern alias Erp_Contracts_BO_SalesOrder;
extern alias Erp_Contracts_BO_Quote;
extern alias Erp_Contracts_BO_Part;
extern alias Erp_Contracts_BO_Customer;
extern alias Erp_Contracts_BO_RMAProc;
extern alias Erp_Contracts_BO_OrderDtlSearch;
extern alias Erp_Contracts_BO_OrderHist;
extern alias Erp_Contracts_BO_QuoteDtlSearch;
extern alias Erp_Contracts_BO_SerialNumberSearch;
extern alias Erp_Contracts_BO_ShipTo;
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Erp.Adapters;
using Erp.UI;
using Ice.Adapters;
using Ice.Lib;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;
//Added for customisation
using System.Collections.Generic;
using System.Reflection;
using Infragistics.Win.UltraWinToolbars;
public partial class Script {
// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
// Begin Wizard Added Module Level Variables **
// End Wizard Added Module Level Variables **
// Add Custom Module Level Variables Here **
public void InitializeCustomCode () {
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
// Begin Wizard Added Variable Initialization
// End Wizard Added Variable Initialization
// Begin Wizard Added Custom Method Calls
// End Wizard Added Custom Method Calls
var objMenu = SalesOrderForm.GetType ().InvokeMember ("baseToolbarsManager", BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic, null, SalesOrderForm, null);
var tools = (UltraToolbarsManager) objMenu;
ButtonTool buttonTool1 = new ButtonTool ("CopySOLine");
tools.Tools.Add (buttonTool1);
PopupMenuTool pop = (PopupMenuTool) tools.Tools["ActionsMenu"]; //this is the pop up menu for the Actions menu item
pop.Tools.AddTool ("CopySOLine");
pop.Tools["CopySOLine"].SharedProps.Caption = "Duplicate SO Line";
pop.Tools["CopySOLine"].SharedProps.AppearancesLarge.Appearance.Image = EpiUIImages.GetImage ("Copy");
pop.Tools["CopySOLine"].SharedProps.AppearancesSmall.Appearance.Image = EpiUIImages.GetImage ("Copy");
pop.Tools["CopySOLine"].ToolClick += CopySelectedSORelLine;
pop.Tools["CopySOLine"].SharedProps.Shortcut = (Shortcut) Shortcut.F12;
}
public void DestroyCustomCode () {
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
// Begin Wizard Added Object Disposal
// End Wizard Added Object Disposal
// Begin Custom Code Disposal
// End Custom Code Disposal
}
private void CopySelectedSORelLine (Object sender, ToolClickEventArgs e) {
//Test to see if there are any selected lines on the POLineRel grid first
EpiUltraGrid SOLinesGrid = (EpiUltraGrid) csm.GetNativeControlReference ("bec51417-b286-4d61-a471-3912bc098905");
if (SOLinesGrid.Selected.Rows.Count > 1) {
MessageBox.Show ("You can only select one line at a time to copy. " + Environment.NewLine + "Current active row will be copied.");
}
try {
SOLinesGrid.Rows[SOLinesGrid.ActiveRow.Index].Selected = true;
SOLinesGrid.OnGridCopySelection (false);
SOLinesGrid.OnGridPasteInsert ();
} catch (System.Exception ex) {
ExceptionBox.Show (ex);
}
}
}