Skip to Content
avatar image
Former Member

how to bind Items to combobox in windows forms SAP B1 SDK C#

Hi Experts,

I am new to the SAP B1 SDK.

Can any one help me how to bind Items from database to Combobox in windows forms using SDK c#.net??

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Jun 07, 2017 at 08:42 AM

    Hi,

    If you are asking about binding the Valid Values to the ComboBox, you can use it as below:

    private void FillValidValues()
            {
                SAPbobsCOM.Recordset oRecSet = default(SAPbobsCOM.Recordset);
                SAPbouiCOM.ButtonCombo oCombo = default(SAPbouiCOM.ButtonCombo);
                try
                {
                    oCombo = (SAPbouiCOM.ButtonCombo)this.m_SBO_Form.Items.Item("Combo").Specific;
                    oRecSet = (Recordset)this.SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                    oRecSet.DoQuery("SELECT Name FROM [@CopyToValuesMaterialRequest] order by Code Asc");
    
    
                    if (oCombo.ValidValues.Count > 0)
                    {
                        for (int i = 0; i <= oCombo.ValidValues.Count; i++)
                        {
                            oCombo.ValidValues.Remove(i, SAPbouiCOM.BoSearchKey.psk_Index);
                        }
    
    
                    }
                    oCombo.ValidValues.Add("", "");
    
                    if (oRecSet.RecordCount > 0)
                    {
                        while (oRecSet.EoF == false)
                        {
                            oCombo.ValidValues.Add(oRecSet.Fields.Item(0).Value.ToString().Trim(), "");
                            oRecSet.MoveNext();
                        }
    
    
                    }
    
                }
                catch (Exception ex)
                {
                    this.SBO_Application.SetStatusBarMessage(ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, true);
                }
            }
    
    
    

    Kind regards,

    ANKIT CHAUHAN

    SAP SME Support

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 08, 2017 at 06:25 AM

    hi Mr.Ankit

    I am getting this error : m_SBO_Form doesnot contain a definition are you missing an assembly reference.

    I am giving my form name but it is not accepting.

    how to resolve this?


    Add comment
    10|10000 characters needed characters exceeded

    • Hi Prasanna,

      You need to use your own variable which you have instantiated for your User Form. Like oForm, oUserForm etc.

      Kind regards,

      ANKIT CHAUHAN

      SAP SME Support