I have a form in my vb project (let's call it frm_UpdateDetails). It contains a user control (Let's call it MyUserControl). The user control has several fields that allow the user to edit entries in the database. There is another form (lets say frm_Main) that calls a method in frm_UpdateDetails called ShowUpdateDetails. ShowUpdateDetails does the following
Dim myRtnValue As Boolean
myUserControl.Connect()
myRtnValue = myUserControl.DisplayData()
Me.ShowDialog()
return myRtnValue
This DisplayData takes data that was pulled in from the database and displays it in the appropriate fields. One of these field is a ComboBox called cmbTitle. The cmbTitle.Text gets set to a value from the DataBase.
I can step through the program and see that at the end of DisplayData() it's text property contains the appropriate data but as soon as I call ShowDialog() the Text of the Combo Box blanks out. I can hide the problem by writing my code
Dim myRtnValue As Boolean
myUserControl.Connect()
Me.Show()
Me.Hide()
myRtnValue = myUserControl.DisplayData()
Me.ShowDialog()
return myRtnValue
As long as I have called Show and triggered the form load before calling DisplayData it is ok, but this is not a true fix. I shouldn't have to show and hide my form before setting it's control properties. There is no code in the load event for my form or for my Custom User Control. No other combo boxes on the form lose their value, only this one (Note this is the only combobox that has a DropDown style of Drop Down. The other ComboBoxes are having their text field set implicitly by setting their SelectedValue properties).
Does anyone out there have any thoughts on what would cause this problem? Is it just a glitch with the .net form implementation?