Topmost problem

obscuregirl

Member
Joined
Sep 13, 2006
Messages
15
Location
UK
Programming Experience
Beginner
Hi
I'm trying to display a progress bar in my application when the user loads a report (Crystal report). I call the form containing the progress bar just before the form containing the reportviewer is called. So the progress bar displays while the reportviewer form is loading. However once the reportviewer form becomes visible, it hides the progress bar form, even though it sometimes takes another few seconds for the actual report to show up.
I've set the Topmost property to True on the progress bar form but it is still not showing on top of the reportviewer form.
Please can anyone help?
 
Progress bar, multithreading

Hi
I'm trying to implement a progress bar so that when a user clicks to open a report, a small form with the progress bar embedded in the statusbar appears to show that something is happening.
I'm very new to VB.NET and multithreading is a bit above my level of understanding so any help would be greatly appreciated!
I've cobbled together some code using a Backgroundworker based on various examples that I've found but I don't really know if it's right.
Basically I have two problems:
1) The progress bar form appears before the report viewer form opens but is then hidden when the report viewer form opens until the report is fully loaded when it is then closed. The Topmost property on the form is set to True and I thought that this coupled with the Backgroundworker would mean that it would stay at the top. Is there something else I need to do?
2) The first time I run this, it appears to work ok (apart from not being at the front). If I then close the reportviewer form and click to open another report, I get a TargetInvocationException. I'm unsure which part of the code it relates to and am not sure how to deal with it or why it's happening.

I've attached text versions of the code so you can see what I'm talking about! Thanks.
 

Attachments

  • frmProgress.txt
    2.5 KB · Views: 28
  • ProgressStatus.txt
    768 bytes · Views: 25
Last edited:
OK, I've got a little further. I was making a call to close the Progress Bar form at the end of the onLoad of the reportviewer form so it was closing it when the form had loaded up but the report still hadn't appeared. I've taken that out so the progress bar shows on top of the reportviewer form but now I'm not sure when to close it down.
I'm not sure if I'm doing this right. I'm opening the progress bar form and the reportviewer form from the same place. Is that right or should I be doing something like calling the reportviewer form from the progress bar form?
Sorry, this is probably a very obvious question but I'm just not getting this multithreading business!
 
Hi,
It is OK to call both progressbar and the form from the same place. But I think the progressbar can be called in a separate thread just before the main report form is called. better still, create a function that will do these works like creating progressbar form, showing it etc. e.g.
Dim l_thread As New System.Threading.Thread(AddressOf OpenProgressBarFunction).

Inside the function, create the progressbar and you can loop it indefinitely os that till the time report is displayed, the progressbar loops.........
Once the report form is displayed, close the thread by calling.
l_thread.abort().
Hope this should solve ur problem.
 
Back
Top