Skip to Content
0

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

Jun 07, 2017 at 06:05 AM

478

avatar image
Former Member

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??

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

2 Answers

ANKIT CHAUHAN
Jun 07, 2017 at 08:42 AM
0

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

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Jun 08, 2017 at 06:25 AM
0

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?


Show 1 Share
10 |10000 characters needed characters left 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

0