Home > Enterprise >  ItemEvent in SAP B1 SDK with a SAP form created in Visual Studio 2015
ItemEvent in SAP B1 SDK with a SAP form created in Visual Studio 2015

Time:06-21

I truly really need your help.

I want to be able to deal with a Click on an Item on my Form which has been created in Visual Studio 2015

this is my Main Methode :

  static void Main(string[] args)
    {
        try
        {
            Application oApp = null;
            if (args.Length < 1)
            {
                oApp = new Application();
            }
            else
            {
                oApp = new Application(args[0]);
            }
            Menu MyMenu = new Menu();
            MyMenu.AddMenuItems();
            oApp.RegisterMenuEventHandler(MyMenu.SBO_Application_MenuEvent);
            
            
            Application.SBO_Application.AppEvent  = new SAPbouiCOM._IApplicationEvents_AppEventEventHandler(SBO_Application_AppEvent);
          
   
            oApp.Run();
        }
        catch (Exception ex)
        {
            System.Windows.Forms.MessageBox.Show(ex.Message);   
        }
    }

and this code is automatically generated by Visual studio when i creat a new SAP B1 Project.

now i want to add an ItemEvent to handle some klick events on some Forms.

when i add this to the code :

Application.SBO_Application.ItemEvent  = new SAPbouiCOM._IApplicationEvents_ItemEventEventHandler(SBO_Application_ItemEvent);

und of course the Methode SBO_Application_ItemEvent then i got a compiler error in this code line that an object reference is requiered for non-static fields...

what did i miss?

I just want to be able to do something when the User clicks on the Grid in my Form.

CodePudding user response:

A Method to add a click event to a grid on a custom user form, using Visual Studio and SAP BUSINESS ONE STUDIO:

  1. Open the .b1f file in visual studio designer.

an example form: an example form:

  1. Click on the Grid you wish to add the event for and navigate to the properties window

  2. Click the lightening symbol to see the events Add Event To Grid

  3. Double click the space next to your Desired Event

visual studio should then add the code for the event as required, something similar to the below should appear in code:

private void docRowGrid_ClickBefore(object sboObject, SAPbouiCOM.SBOItemEventArg 
pVal, ref bool BubbleEvent)
{
}
  • Related