on 07-10-2014 12:46 AM
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
Hi Mike!
Instead of select method you may set the datasource value to 0.
oComboBox.Select(0, BoSearchKey.psk_Index)
Form.Datasources.userdatasource.item([INDEX]).value = 0
This speads up a little bit, because combobox value is selected by UI API based on a datasource, not by you.
Regards,
J.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Janos, hope all is well.
Are you suggesting that I create a user defined data source to hold the Record Set data I am filling the combo with, then bind the user defined data source to the combo? I see how then, I could use your idea of assigning the index of the data source.
Also, wouldn't this just rearrange the order of the data source, instead of having it be the selected item in the combo?
Appreciate your input,
Mike
Update: No Joy on data source index change idea. Changing the data source order does not make the item selected in the combo.
Message was edited by: Mike Hardwick
Hi Mike,
Just an (more or less) educated guess, could you please try to move the line oComboBox.Select(0, BoSearchKey.psk_Index) outside the try catch ?
So something like:
Public Sub LoadComboBoxes()
Dim oRecordset As SAPbobsCOM.Recordset = OMComp.GetBusinessObject(BoObjectTypes.BoRecordset)
oForm = OMApp.Forms.Item(FormNM)
Try
oComboBox = oForm.Items.Item("cmbSTAT").Specific
'etc. etc.... (your code as is, except for the oComboBox.Select bit)
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
Try
oComboBox.Select(0, BoSearchKey.psk_Index)
Catch ex As Exception
Throw
End Try
End Sub
P.S. Using GC with the DI API, often does more harm than good. You could replace these 2 lines:
GC.WaitForPendingFinalizers()
GC.Collect()
with
oRecordset = nothing
Regards,
Johan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
107 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
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.