📚 SAP Business One SDK Help

RegisterWidget Method
See Also  Example
wrParams
Contains the registration parameters of the widget.

Description

Registers a new add-on widget type.

Syntax

Visual Basic
Public Sub RegisterWidget( _
   ByVal wrParams As WidgetRegParams _
) 

Parameters

wrParams
Contains the registration parameters of the widget.

Example

Registering Widgets (C#)Copy Code
            try 
            { 
                SAPbouiCOM.Cockpits ckpts = sbo_Application.Cockpits; 
 
                //Pop up the dialog now. 
                RegisterWidget regWdt = new RegisterWidget(); 
                regWdt.ShowDialog(); 
 
                if(regWdt.DialogResult == DialogResult.OK) 
                {                                     
                    string strWidgetType = regWdt.GetWidgetType(); 
                    string strWidgetName = regWdt.GetWidgetName(); 
                    string strCategory = regWdt.GetWidgetCategory(); 
                    int iWidth = (int)regWdt.GetWidgetWidth(); 
                    int iHeight = (int)regWdt.GetWidgetHeight(); 
                    string strImagePath = regWdt.GetImagePath(); 
 
                    //Widget Registration Parameters. 
                    SAPbouiCOM.WidgetRegParams wrp = (SAPbouiCOM.WidgetRegParams)sbo_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_WidgetRegParams); 
                    wrp.WidgetType = "AddonWidget"; 
                    wrp.WidgetName = "Addon_Menu"; 
                    wrp.ImagePath = "D:\\CockPit\\addon_wdt.png"; 
                    wrp.Width = 50; 
                    wrp.Height = 40; 
                    wrp.CategoryUID = "General Widgets";    //You can add new widget category by providing new category names 
 
                    wrp.WidgetType = strWidgetType; 
                    wrp.WidgetName = strWidgetName; 
                    wrp.ImagePath = strImagePath; 
                    wrp.Width = iWidth; 
                    wrp.Height = iHeight; 
                    wrp.CategoryUID = strCategory; 
 
                    //Register Add-on widget prototype. 
                    ckpts.RegisterWidget(wrp); 
                } 
 
            } 
            catch (Exception ex) 
            { 
                string strErrAlert = "Errors:\n\n"; 
                MessageBox.Show(strErrAlert + ex.Message); 
            } 

See Also