Skip to Content
0
Former Member
Jul 09, 2014 at 11:46 PM

ComboBox.Select Method Taking Long Time?

25 Views

Hello experts,

The combobox select method takes a long time on the second use of the add-on form. In my method, I check for existing data in the form combobox and if not empty I remove all items, then reload the combo. After reload, Iuse the combo.select method to actually select the preferred item before displaying the form in SAP.

Any help will be appreciated,

Thanks,

Mike

See code below:

Public Sub LoadComboBoxes()

Dim oRecordset As SAPbobsCOM.Recordset = OMComp.GetBusinessObject(BoObjectTypes.BoRecordset)

oForm = OMApp.Forms.Item(FormNM)

Try

oComboBox = oForm.Items.Item("cmbSTAT").Specific

'Empty Combo

If oComboBox.ValidValues.Count <> 0 Then

For i As Integer = oComboBox.ValidValues.Count - 1 To 0 Step -1

oComboBox.ValidValues.Remove(i, BoSearchKey.psk_Index)

Next

End If

'Fill Combo

oComboBox.ValidValues.Add("ALL", "0")

oRecordset.DoQuery(QueryStrings("Status"))

oRecordset.MoveFirst()

While oRecordset.EoF = False

oComboBox.ValidValues.Add(oRecordset.Fields.Item("DESCRIPTION").Value, oRecordset.Fields.Item("SEQNO").Value) oRecordset.MoveNext()

End While

oComboBox.Select(0, BoSearchKey.psk_Index)

Catch ex As Exception

Throw

Finally

If Not oRecordset Is Nothing Then

System.Runtime.InteropServices.Marshal.ReleaseComObject(oRecordset)

GC.WaitForPendingFinalizers()

GC.Collect()

End If

End Try

End Sub