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 use 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.