如何在C#中将组合框绑定到recorset

2020-09-16 00:17发布

点击此处---> 群内免费提供SAP练习系统(在群公告中)加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)伙计们,我真的很新,我想将组合框...

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


伙计们,我真的很新,我想将组合框与付款条件绑定在一起,我使用此代码但没有用,有人可以帮我吗?

谢谢

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

2条回答
小c菟菟
2020-09-16 00:33

嗨,

私有无效BindComboBox(SAPbouiCOM.ComboBox oCombo)
         {
             尝试
             {
                 字符串vDoQuery_string = null;
                 int vRecordsetIndex_long;
                 int vRecordsetCount_long;

                 SAPbobsCOM.Recordset oRecordset = null;
                 oRecordset =(((SAPbobsCOM.Recordset)(ServiceLocator.SboCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset))));;
                 vDoQuery_string ="选择来自OCRD的CardCode,CardName";
                 oRecordset.DoQuery(vDoQuery_string);
                 vRecordsetCount_long = oRecordset.RecordCount;
                 oRecordset.MoveFirst();
                //oCombo.ValidValues.Add("0","-选择CardCode-");//添加默认值
                 对于(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();
                 }
                 oCombo.Select(2,BoSearchKey.psk_Index);
                 oRecordset = null;
                 System.GC.Collect();
             }
             捕获(System.Exception ex)
             {
                 System.Windows.Forms.MessageBox.Show(ex.Message);
                //oApplication.MessageBox("附加错误:Error-3256" + Error.Message,1,"确定","",""); //我的错误代码
             }
         } 

您可以在combox中调用上述" BindComboBox"方法。

此致

Chenna。

一周热门 更多>