Skip to Content
0

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

Jul 04, 2017 at 01:32 PM

121

avatar image
Former Member

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.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

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

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,

Share
10 |10000 characters needed characters left characters exceeded