cancel
Showing results for 
Search instead for 
Did you mean: 

How to clear combobox

Former Member
0 Kudos

Hi All,

I want to fill my combobox on the basis of values selected in other combobox. For this I have to Clear the combobox. I have used Remove method with SAPbouiCOM.BoSearchKey.psk_Index.

But its giving error. Whats the process to Clear Combobox.

Thanks,

Anuj Singh

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member

Hi ,

You can use the below code.

  

int Count = oComboBox.ValidValues.Count;           

for (int i = 0; i < Count; i++)

            {

                oComboBox.ValidValues.Remove(oComboBox.ValidValues.Count - 1, SAPbouiCOM.

BoSearchKey.psk_Index);            

            }

Cheers,

Tamara

Former Member
0 Kudos

Thanks

Former Member
0 Kudos

Hello anuj singh,

this is how it works here since a long time:


        Do While oComboBox.ValidValues.Count > 0
            oComboBox.ValidValues.Remove(0, SAPbouiCOM.BoSearchKey.psk_Index)
        Loop

On every Remove the indexes are shifting so the save method is to use always index=0

Another way could be to Remove from end and then backwards through the indexes. Then the lower indexes stay the same while removing.

Cheers,

Roland

Former Member
0 Kudos

Yes, of course.

My mistake!

Former Member
0 Kudos

Anuj,

Should work this way.


      Dim item As SAPbouiCOM.Item = YourItem
      Dim itemCombo As SAPbouiCOM.ComboBox = item.Specific
      For index As Integer = 0 To itemCombo.ValidValues.Count - 1
        itemCombo.ValidValues.Remove(index, SAPbouiCOM.BoSearchKey.psk_Index)
      Next index

former_member196647
Contributor
0 Kudos

Hello,

There is a small problem with this code. As the loop progresses, the value of index increases whereas the index value of validvalues keeps on decreasing with every deletion. So, if there are 5 values, by the time the index reaches 4, the validvalues index is only 1.

Make following modifications in the code:


      Dim item As SAPbouiCOM.Item = YourItem
      Dim itemCombo As SAPbouiCOM.ComboBox = item.Specific
      For index As Integer = 0 To itemCombo.ValidValues.Count - 1
        itemCombo.ValidValues.Remove(0, SAPbouiCOM.BoSearchKey.psk_Index)
      Next index

Rahul

Former Member
0 Kudos

Hello anuj,

I think you can solve your problem by using the object ValidValues and the methode remove.

See the SDK help for more info

HTH

Regards Teun