Skip to Content
0

how to bind a combobox with an recorset in c#

Nov 06, 2017 at 10:42 AM

107

avatar image
Former Member

hey guys, im really new i would like to bind a combobox with payment terms, i use this code but didn't work, can anybody help me?

thank you

SAPbobsCOM.Recordset orec = null; orec = ((SAPbobsCOM.Recordset)(oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset))); orec.DoQuery("select GroupNum,PymntGroup from OCTG"); while (!orec.EoF) { ComboBox1.ValidValues.Add(orec.Fields.Item("GroupNum").Value.ToString(), orec.Fields.Item("PymntGroup").Value.ToString()); orec.MoveNext();

10 |10000 characters needed characters left characters exceeded
Hi Peralta,

private void Load_TaskListComboBox(SAPbouiCOM.ComboBox oCombo)
{
try
{
string vDoQuery_string = null;
int vRecordsetIndex_long;
int vRecordsetCount_long;

SAPbobsCOM.Recordset oRecordset = null;
oRecordset = ((SAPbobsCOM.Recordset)(ServiceLocator.SboCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)));
vDoQuery_string = "SELECT * FROM PMC6 WHERE NAME!='-'";
oRecordset.DoQuery(vDoQuery_string);
vRecordsetCount_long = oRecordset.RecordCount;
oRecordset.MoveFirst();
//oCombo.ValidValues.Add("0", "-- Select Stages --");// Add the default value
for (vRecordsetIndex_long = 0; vRecordsetIndex_long <= vRecordsetCount_long - 1; vRecordsetIndex_long++)
{
oCombo.ValidValues.Add(System.Convert.ToString(oRecordset.Fields.Item(1).Value), System.Convert.ToString(oRecordset.Fields.Item(0).Value));
oRecordset.MoveNext();
}
oRecordset = null;
System.GC.Collect();
}
catch (System.Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
} //In your Form Bind Drop-down list SAPbouiCOM.Item oItem = null; SAPbouiCOM.ComboBox ComBox = null; oItem = oForm.Items.Add("ddl_Task", SAPbouiCOM.BoFormItemTypes.it_COMBO_BOX); oItem = oForm.Items.Item("ddl_Task"); stageIdCmBx = ((SAPbouiCOM.ComboBox)(oItem.Specific)); Load_TaskListComboBox(ComBox); if (Task != "" && Task != "0") { ((SAPbouiCOM.ComboBox)(oForm.Items.Item("ddl_Task").Specific)).Select(Task, SAPbouiCOM.BoSearchKey.psk_ByValue); }

Thanks,

Chenna.

0
* Please Login or Register to Answer, Follow or Comment.

1 Answer

ANKIT CHAUHAN
Nov 06, 2017 at 10:57 AM
0

Hi,

Check whether it does help or not?

SAPbobsCOM.Recordset oRecSet = default(SAPbobsCOM.Recordset);
            SAPbouiCOM.ButtonCombo oCombo = default(SAPbouiCOM.ButtonCombo);
            try
            {
                oCombo = (SAPbouiCOM.ButtonCombo)this.m_SBO_Form.Items.Item(enControlName.btnCombo).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