UserControl hangs on to SelectedText

  • Thread starter Thread starter Troy
  • Start date Start date
T

Troy

A user control with
1 combobox
1 button
has a default constructor.
The control has public properties to set the combobox
Datasource, DisplayMember and ValueMember properties.
These are set in the Forms Load event handler.

The combo box control has its text selected even though
it doesnt have focus when the form displays.
I've been looking for something I've done to cause this
but with no luck so far. Any ideas?

Thanks,
troy
 
Ok, i found this after a day of headaches. Wanted to post the cause/cure in case anyone else runs into this

The combo box is being sized based on the visibility of the button.
When the user control initializes it makes the button visible which resizes the combobox
*resizing causes the text to become selected
After the entire form loads, the combo box no longer has focus BUTshows its text as selected

I'm showing/hiding the button based on user permissions as the form is loaded. After resizing the combobo
in the buttons visible changed event I just added the statement: combobox1.selecttext(999,0)

Now its all good.
 
Back
Top