Skip to Content
avatar image
Former Member

How to Populating values in drop down based on other drop down change in User created Form using c#

In my User Defined Form, I have two drop down(Combobox) list, "Deparments" and "Developers".

"Deparments" (combobox) that contain list of all departments in a company.

I have another field which is an input field called "Developers".

When a department name get selected change into a Departments drop-down, then bind all related Developers names into "Developers" comboBox,

Thank you.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Jul 20, 2017 at 09:59 AM

    Hi All,

    Here is the working code for drop down onchange event , bind another dropdown related values.

    public void SBO_Application_ItemEvent(string FormUID, ref SAPbouiCOM.ItemEvent pVal, out bool BubbleEvent)
            {
    BubbleEvent = true;
    try
                {
                    if ((pVal.FormUID == "WID_MyFromID"))
                    {
    if (((pVal.ItemUID == "ddl_Department") & (pVal.EventType == SAPbouiCOM.BoEventTypes.et_COMBO_SELECT) & (pVal.Before_Action == false)))
                    {
                        dropDownSelectChange();
                    }
    }
    }catch (System.Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(ex.Message);
                }
    }
    private void dropDownSelectChange()
            {
                try
                {
                    SetApplication();
                    SAPbouiCOM.ComboBox cb = null;
                    SAPbouiCOM.Item oItem = null;
                    SAPbouiCOM.Form oForm = SBO_Application.Forms.ActiveForm;
                    if (oForm.UniqueID == "FP_TaskTypeForm")
                    {
                        var DeptId= "";
                        string descrition = "";
                        SAPbouiCOM.ComboBox cbxDepartment = (SAPbouiCOM.ComboBox)oForm.Items.Item("ddl_Department").Specific;
                        if (cbxDepartment.Selected != null)
                        {
                           descrition = cbxDepartment.Selected.Description;
                            DeptId= cbxDepartment.Selected.Value;
                        }
                        try
                        {
                            oItem = oForm.Items.Item("ddl_Developers");
                            cb = ((SAPbouiCOM.ComboBox)(oItem.Specific));
                            int Count = cb.ValidValues.Count;
                            for (int i = 0; i < Count; i++)
                            {
                                cb.ValidValues.Remove(cb.ValidValues.Count - 1, SAPbouiCOM.BoSearchKey.psk_Index);
                            }
                            BindDevelopersListComboBox(cb, Convert.ToInt32(DeptId));
                        }
                        catch (System.Exception ex)
                        {
                            System.Windows.Forms.MessageBox.Show(ex.Message);
                        }
                    }
                }
                catch (System.Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(ex.Message);
                }
            }
    private void BindDevelopersListComboBox(SAPbouiCOM.ComboBox oCombo, int ID)
            {
    
    //Here drop down binding logic code only.
            }

    Thanks,

    Add comment
    10|10000 characters needed characters exceeded