0

I have on a form a UserControl that I use as a Data-Entry form. I show and hide it constantly with new data.

Often (not all the times) the same two memo-boxes are shown on the screen first for a second, and then the full control is visible.

I found this link, I'm not sure if that's my solution, but in any case I don't know where to call it and when.

EDIT: I noticed that it happens 'only' if the program is idle for a couple of minutes. I could show and hide the control 10 times one after the other no problem. but if I hide it and show it again after 2-3 minutes then I get this behavior.

I guess it has to do with the time it takes to reconnect to the MsSQL database to pull the data. But how can I tell this 2 boxes to stay invisible like there parent until the parent is ready to show?

Community
  • 1
  • 1
Ezi
  • 2,212
  • 8
  • 33
  • 60
  • What are you doing immediately after showing the control but before returning to the main event loop? Basically it sounds like there is something else going on before the controls get an opportunity to paint, e.g. database access or other network access. The suggestion would be to keep the control loaded but with visible=false until the last possible moment. – Ben May 14 '12 at 20:02
  • I do the TicketsBox.Visible = True the last thing possible... – Ezi May 14 '12 at 20:06
  • Do you do TicketsBox.Visible=False first though or does it start out visible? Put a breakpoint on the Load event to check. – Ben May 14 '12 at 20:09
  • Try to move your TicketsBox.Visible = True inside the VisibleChanged event. – Steve May 14 '12 at 20:55
  • Unless you have asynch binding then the page should not begin to paint until it is fully rendered. Are you binding asynch or updating data via background worker. If the data so dynamic that you cannot hold it in a variable rather than going back to the DB every get? – paparazzo May 14 '12 at 20:58
  • TicketsBox is the usercontrol. which VisibleChanged event can I put it in? – Ezi May 14 '12 at 20:58
  • @Blam: Its not binding in the background. The data is loaded using EF-4.0, every time its a different record so it needs to go to the DB. – Ezi May 14 '12 at 21:01
  • OK, hide show kind of inferred same data. So when you show how does it know to get fresh data? – paparazzo May 14 '12 at 21:10
  • I set the binding.datasource before making it visible. – Ezi May 14 '12 at 21:11
  • OK I would close it and new it and pass the datasource in the ctor. – paparazzo May 14 '12 at 23:17
  • Don't set the control to visible until all the database activity is completely finished. – Ben May 15 '12 at 07:27
  • How would I know when its done? – Ezi May 15 '12 at 14:11

1 Answers1

0

This is really sloppy and there is probably a better solution but what if you tried something like this.

If SlowControl.visible = True Then
FastControl1.visible = True
FastControl2.visible = True
End If

I'm not sure if that will work since i don't know how to replicate the problem to test but try it out and see if it delays the 2 that are ahead of the game a bit and doesn't show them until the others show.

Tony318
  • 552
  • 2
  • 9