cancel
Showing results for 
Search instead for 
Did you mean: 

Add Combobox Value in Grid

Former Member
0 Kudos

Hi All,

      I designed screen using Screen Painter. It has one Combobox Column.we can't add Combobox Value using Screen Painter.

So How to add Combobox value on it.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

This is an easy way to do it.

objMatrix.Columns.Item("colName").ValidValues.Add("value", "desc")

Answers (1)

Answers (1)

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Lakshmi,

The field that you have bind with the ComboBox, should have the valid values. After that you will be able to use it as you want.

If you need code to do it. Follow it

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(enControlName.btnCombo).Specific;

                oRecSet = (Recordset)this.SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);

                oRecSet.DoQuery("SELECT Name FROM [@CopyToValues] 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);

            }

        }

Also if you need combobox in Grid, use it as follows:

oEditColumn = ((SAPbouiCOM.EditTextColumn)(oGrid.Columns.Item("Select")));

                oEditColumn.Type = BoGridColumnType.gct_CheckBox;

Hope it helps.

Thanks & Regards

Ankit Chauhan