Skip to Content
0
Sep 06, 2018 at 11:03 AM

manually creating events for button

125 Views

I am creating an addon and for that i have successfully connected di and ui api. i am creating everything (forms, buttons, textbox etc ) manually by code to learn as this is my first one. when i debug i can see my form with all the fields i created. here is the code for form creation.

      SAPbouiCOM.FormCreationParams oCreationParams = null;
      oCreationParams = ((SAPbouiCOM.FormCreationParams(SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_FormCreationParams)));
      oCreationParams.BorderStyle = SAPbouiCOM.BoFormBorderStyle.fbs_Fixed;
      oCreationParams.UniqueID = "Form2";
      oForm = SBO_Application.Forms.AddEx(oCreationParams);
      oForm.Title = "Simple Form";
      oForm.Left = 417;
      oForm.Top = 520;
      oForm.ClientHeight = 610;
      oForm.ClientWidth = 770;
here is how i create my button
     SAPbouiCOM.Button oButton = null;
     oItem = oForm.Items.Add("Button1", SAPbouiCOM.BoFormItemTypes.it_BUTTON);
     oItem.Left = 6;
     oItem.Width = 65;
     oItem.Top = 51;
     oItem.Height = 19;
     oItem.Enabled = true;
     oButton = ((SAPbouiCOM.Button)(oItem.Specific));
     oButton.Caption = "Add";

the problem is when i try to add the values of textbox in database on button click event, i am not able to generate a button click event.

from my knowledge when we create a button from toolbox and uses system form, it automatically initializes the button ON InitializeComponent() function and also creates a delegates pointing to button click event.

May i know how to achieve all these through code. i tried to initialize button through my manual code and also created delegates pointing to a button click function but i was unable to achieve my result.