cancel
Showing results for 
Search instead for 
Did you mean: 

Clearing a ComboBox

Former Member
0 Kudos

Good Day

Experts:

I am having all kind of trouble here today with my combobox. So, I am hoping one of you have had a similar problem and could help. I have a really basic form with 4 controls...2 Comboboxes and 2 Textboxes.

When the screen opens, the 2 Comboboxes are loaded with the valid values and then the last visited record is loaded on the screen. This is all good and works great. When the Find MenuEvent is selected, I run a routine to clear the datasources attached to all 4 of the controls and then set the cursor position. All the data is gones from the screen. Here is where the problem is...when I execute the FIND stepping through the code, the data is still hanging around "behind the scenes" for my comboboxes. Here is the code I use to check for what the User has selected in the Combobox:

Dim UserCombo As SAPbouiCOM.ComboBox

UserCombo = PrintForm.Items.Item("cmbUsrCode").Specific

Dim User As String = UserCombo.Selected.Value

Nothing is on the screen but User is showing the value that use to be on the screen before I ran the Cleardatasources behind the Find MenuEvent.

This is really perplexing to me on how fix this.

Any help is appeciated,

Ed

Accepted Solutions (1)

Accepted Solutions (1)

Nussi
Active Contributor
0 Kudos

Ed,

i wrote a function for this and i shared this code already with Rune.

feel free to also use it - call this code when you change the mode.

it clears the values and kills the last shown value.

but what you have to do than is to add the validvalues again.

[Link|]

regards

David

Former Member
0 Kudos

Hello:

David...thanks for replying. It has been one of those days for me here. When I click the link to see your routine, I cannot get to the code to the right that is off the screen. I have no horizontal scroll bar. Do I have to change anything here in my settings to see the link all the way to the right?

Appreciate the help,

EJD

Nussi
Active Contributor
0 Kudos

iam using mozilla and i see it - if you want to i post the code here again

lg

Former Member
0 Kudos

David:

That would be great if you could. This way won't miss anything off to the right.

Thanks again,

EJD

Nussi
Active Contributor
0 Kudos

ok Ed,

here it is - without the code markup:

public static void ClearCombo(string FormUID, string ItemUID)

{

int count;

try

{

if ( ((SAPbouiCOM.ComboBox)(SBO_Application.Forms.Item(FormUID).Items.Item(ItemUID).Specific)).ValidValues.Count > 0 )

{

count = ((SAPbouiCOM.ComboBox)(SBO_Application.Forms.Item(FormUID).Items.Item(ItemUID).Specific)).ValidValues.Count;

for (int i = 1; i <= count; i++)

{

((SAPbouiCOM.ComboBox)(SBO_Application.Forms.Item(FormUID).Items.Item(ItemUID).Specific)).ValidValues.Remove(count - i - 0, SAPbouiCOM.BoSearchKey.psk_Index);

}

((SAPbouiCOM.ComboBox)(SBO_Application.Forms.Item(FormUID).Items.Item(ItemUID).Specific)).ValidValues.Add("0", " ");

((SAPbouiCOM.ComboBox)(SBO_Application.Forms.Item(FormUID).Items.Item(ItemUID).Specific)).Select("0", SAPbouiCOM.BoSearchKey.psk_ByValue);

((SAPbouiCOM.ComboBox)(SBO_Application.Forms.Item(FormUID).Items.Item(ItemUID).Specific)).ValidValues.Remove(" ", SAPbouiCOM.BoSearchKey.psk_ByDescription);

}

}

catch (Exception er)

{

globals.AppendTextToFile("B1C_AddOn.log", "#" + Convert.ToString(DateTime.Now) + "# ERROR: " + er.Message + " [globals.ClearCombo]");

}

finally

{

GC.Collect();

}

}

regards

David

Former Member
0 Kudos

Thanks...

Answers (0)