11-16-2016 9:04 AM - edited 02-03-2024 8:07 PM
I am using SAP Business One 9.2 SDK UI API (C#) to manipulate a system form (Items form specifically). I would like to place a new button and attach functionality (event listener to it). I am subscribed to the Menu Event listener with:
Application.MenuEvent += new SAPbouiCOM._IApplicationEvents_MenuEventEventHandler();
And If the clicked menu's ID (and beforevent == false) isthe Item form's menuid, I grab the active form and try to add a new button. Code:
var oForm = SBOApp.Forms.ActiveForm;
oForm.PaneLevel = 0;
Button megsemBtn = (Button)oForm.Items.Item("2").Specific;//the cancel button
Item newBtn = oForm.Items.Add("newBtn", BoFormItemTypes.it_BUTTON);
newBtn.Left = megsemBtn.Left + 200;
newBtn.Top = megsemBtn.Left;
Button newBtnBtn = (Button)newBtn.Specific;
newBtnBtn.Caption = "test";
newBtn.Width = 80;
newBtn.Height = megsemBtn.Height;
If I open the form, the button is displayed correctly (even though it appears ~0.5 sec after the form is displayed), but If I resize the From, it either goes downwards a bit, or completely leaves the form (it exists, I checked, I just can't see it). The other buttons scale perfectly with the window. Why this one isn't? I even check the XML export of the form (with the button added) and it looks the same.
Hi Szabolcs,
First of all, I would like to suggest you to use the ItemEvent, in specific event et_FORM_DRAW.
About your code. I believe that you have a mistake in your code.
newBtn.Top = megsemBtn.Left;
I believe that you want is this:
newBtn.Top = megsemBtn.Top;
Kind Regards,
Diego Lother
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
10 | |
10 | |
6 | |
5 | |
5 | |
5 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.