on 06-25-2010 8:16 PM
An apology for my English, I'm trying to do a comboBox filled with my Business Partners names and codes, but I can't.
I Modify part of the examples and this is the code that I use:
SAPbobsCOM.BusinessPartners oBusinessPartner;
SAPbobsCOM.Recordset oRecordSet;
oRecordSet = (SAPbobsCOM.Recordset) SAPConn.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
oBusinessPartner = (SAPbobsCOM.BusinessPartners) SAPConn.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners);
try
{
Combo1.Items.Clear();
while (!(oRecordSet.EoF == true))
{
oBusinessPartner.GetByKey(oRecordSet.Fields.Item(0).Value.ToString());
Combo1.Items.Add(oBusinessPartner.CardCode);
oRecordSet.MoveNext();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
Edited by: gaestudio on Jun 25, 2010 9:17 PM
Hi,
The way you have written code to get the Business Partners is not correct. You should bind both value and description to combobox. Use this below code.
DimoComboBox As SAPbouiCOM.ComboBox
Dim RS As SAPbobsCOM.Recordset
RS = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
RS.DoQuery("SELECT T0.[CardCode], T0.[CardName] FROM OCRD T0")
RS.MoveFirst()
While RS.EoF = False
oComboBox.ValidValues.Add(RS.Fields.Item("CardCode").Value, RS.Fields.Item("CardName").Value)
RS.MoveNext()
End While
Note:Your combobox should be bound with datasource
Regards,
Noor Hussain
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
102 | |
12 | |
11 | |
6 | |
6 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.