C
cms0007
I am using C# on a windows form with three tabs. Each tab holds a user
control and there are several combo boxes on each user control. On all
three user controls there is a combo box that contains information from
the same location in a database. but the information is displayed
differently in each instance. In one combo box all values from the
table are displayed, on another box only the values that meet a certain
criteria are displayed and on the third combo box only the values that
meet an additional criteria are displayed so all three display
different information from the same source. On one of the controls I
can update the information in the DB. When I do so I want the other
combo boxes on the other user controls to update their information,
essentially requery the database and redisplay the new information.
This works fine for the combo box that is on the user control in focus
but the user controls on the other two tabs that were not in focus when
there combobox data was updated seem to lose the ability to repaint
themselves. However they do seem to have the updated information. I
can click where the drop down arrow is though I cannot see the drop
down arrow. The combo box will drop down and show the values inside
though the text box portion will not repaint. I can scroll through the
list of values in the dropdown though I cannot see the combo box
scrolling and I can select a value, though I cannot see the value I
scrolled to. The combo boxes that were out of focus when their data
was updated will not repaint until I close and reopen the form. I also
tried a different method of throwing an event on the user control in
focus that told the parent form that the combo boxes need to be
updated. The parent form in turn would notify the other user controls
that they needed to update their combo boxes by setting a variable and
then on the Enter event on the other user controls I checked the
variable to see if it was true when the user control comes into focus
and if so would requery the info in the database and refill the combo
box but this did not work either. The combo box will not repaint it
self even though its info if updated when the combo is in focus it
appears.
It seems this has something to do with the idea that you should not
update the UI directly from a worker thread but should call the UI's
Invoke method for updating which I tried doing as well but it does not
seem to work either.
control and there are several combo boxes on each user control. On all
three user controls there is a combo box that contains information from
the same location in a database. but the information is displayed
differently in each instance. In one combo box all values from the
table are displayed, on another box only the values that meet a certain
criteria are displayed and on the third combo box only the values that
meet an additional criteria are displayed so all three display
different information from the same source. On one of the controls I
can update the information in the DB. When I do so I want the other
combo boxes on the other user controls to update their information,
essentially requery the database and redisplay the new information.
This works fine for the combo box that is on the user control in focus
but the user controls on the other two tabs that were not in focus when
there combobox data was updated seem to lose the ability to repaint
themselves. However they do seem to have the updated information. I
can click where the drop down arrow is though I cannot see the drop
down arrow. The combo box will drop down and show the values inside
though the text box portion will not repaint. I can scroll through the
list of values in the dropdown though I cannot see the combo box
scrolling and I can select a value, though I cannot see the value I
scrolled to. The combo boxes that were out of focus when their data
was updated will not repaint until I close and reopen the form. I also
tried a different method of throwing an event on the user control in
focus that told the parent form that the combo boxes need to be
updated. The parent form in turn would notify the other user controls
that they needed to update their combo boxes by setting a variable and
then on the Enter event on the other user controls I checked the
variable to see if it was true when the user control comes into focus
and if so would requery the info in the database and refill the combo
box but this did not work either. The combo box will not repaint it
self even though its info if updated when the combo is in focus it
appears.
It seems this has something to do with the idea that you should not
update the UI directly from a worker thread but should call the UI's
Invoke method for updating which I tried doing as well but it does not
seem to work either.