1

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.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
memo_star
  • 109
  • 2
  • 8

1 Answers1

0

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)
{
}
Praxiom
  • 578
  • 1
  • 8
  • 21
  • but as i see you are the one who could answer my next question. When someone clicks on my Grid i get a path where a file is saved. its like \\sap01\archive\filename.pdf. now i want to open this file after clicking on it. can you help me with that? – memo_star Jun 20 '22 at 16:58
  • no problem :) try: System.Diagnostics.Process.Start(@"\\sap01\archive\filename.pdf") – Praxiom Jun 21 '22 at 06:10
  • ** you are the best** That woked perfectly! you bring it directly to the point. Do not you like to give online lessons? :) – memo_star Jun 21 '22 at 13:49