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

2020-09-16 00:17发布

         点击此处--->   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();

         点击此处--->   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条回答
我是小鹏鹏啊
1楼-- · 2020-09-16 00:33

嗨,

检查是否有帮助?

 SAPbobsCOM.Recordset oRecSet =默认值(SAPbobsCOM.Recordset);
             SAPbouiCOM.ButtonCombo oCombo =默认值(SAPbouiCOM.ButtonCombo);
             尝试
             {
                 oCombo =(SAPbouiCOM.ButtonCombo)this.m_SBO_Form.Items.Item(enControlName.btnCombo).Specific;
                 oRecSet =(记录集)this.SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                 oRecSet.DoQuery("按代码Asc从[@CopyToValuesMaterialRequest]顺序中选择名称");
                 如果(oCombo.ValidValues.Count> 0)
                 {
                     对于(int i = 0; i <= oCombo.ValidValues.Count; i ++)
                     {
                         oCombo.ValidValues.Remove(i,SAPbouiCOM.BoSearchKey.psk_Index);
                     }
                 }
                 oCombo.ValidValues.Add("","");
                 如果(oRecSet.RecordCount> 0)
                 {
                     while(oRecSet.EoF == false)
                     {
                         oCombo.ValidValues.Add(oRecSet.Fields.Item(0).Value.ToString()。Trim(),"");
                         oRecSet.MoveNext();
                     }
                 }
             }
             抓住(前例外)
             {
                 this.SBO_Application.SetStatusBarMessage(ex.Message,SAPbouiCOM.BoMessageTime.bmt_Short,true);
             } 

亲切的问候,

ANKIT CHAUHAN

SAP SME支持

小c菟菟
2楼-- · 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。

一周热门 更多>