ComboBox acting strange.

vinnie881

Well-known member
Joined
Sep 3, 2006
Messages
152
Programming Experience
3-5
I have a .net ComboBox on a windows form that is populated with a datatable.

I have a public function that populates this combobox

VB.NET:
Public sub mypublicFunction()
me.CB_MyComboBox.SelectedValue = "IL"
end sub

When this function is called post the Show event of the form where the combo box resides it works perfect.

However if I call this command Pre the Show event, The combobox selected value does not change.

I need to get it to function pre.

Any suggestions on a workaround?
 
That code doesn't populate the ComboBox. It selects a item in a ComboBox that must already be populated. The question is: have you added any items to the ComboBox at the point you call this method?
 
As stated in the question the combo box is populated with the datatable, and yes it is done prior to this public function being called.

It was ment to say the value is selected(Not populated). None the less same question.

Any thoughts?

I was able to get a workaround by simply using the .show method prior to calling the function, but I would still like to know why this is the case.
 
Back
Top