473,419 Members | 1,697 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,419 software developers and data experts.

Progressbar and treeview stops refreshing

I am writing my first VB.Net program and have come across an
interesting problem. My department generates large volumes of
documents. By law we are required to keep the documents for a specific
period of time based on several factors.

The IT department has been asked to develop a program to assist in
archiving the older documents. We have a stored procedure that returns
the docket numbers to the cases that may have documents which are
eligible to be archived. Based on the docket number the path to the
directory where the documents are stored can be calculated.

I developed several classes that takes the list of docket numbers and
checks the file sizes of each document and divides the directories and
documents into CD volumes. It first creates a list of CD volumes and
which directories and transcripts are in each volume. It then
populates a treeview with the information.

As the program does its job it uses a progressbar to let the user know
how far along it is and after fully populating a CD volume node with
the associated directories and transcripts in those directories is
refreshes. The effect is that the user sees each CD node pop into view
when it is fully populated.

The problem is, however, that sometimes the progressbar and the
treeview stop refreshing. This gives the appearance that the program
has hung. But in the end the treeview and progress bar suddenly
refresh and all of the CD volumes will pop into view. There is no way
for the code that increments the progressbar or the code that updates
the treeview can be skipped and have the nodes still be populated. Can
anyone tell me what may be going on? Below is the sub where the nodes
are being poplulated:

Private Sub DisplayVolumes()
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim v As Volume
Dim d As Directory
Dim t As Transcript
InitImageList()
vL = aM.GetVolumes()
For i = 1 To vL.Count
v = vL(i)
ProgressBar1.Maximum = v.Count
StatusBar1.Text = "Populating Nodes for CD-" & i
VolumeTreeView.Nodes.Add(New TreeNode(v.Name, 1, 2))
Dim n As TreeNode = VolumeTreeView.Nodes(i - 1)
For j = 1 To v.Count
ProgressBar1.Value = j
d = v.GetDirectory(j)
n.Nodes.Add(New TreeNode(d.Name, 3, 4))
Dim m As TreeNode = n.Nodes(j - 1)
For k = 1 To d.Count
t = d.GetTranscript(k)
m.Nodes.Add(New TreeNode(t.Name, 5, 5))
Next
Next
VolumeTreeView.Refresh()
Next
End Sub

Mar 7 '06 #1
3 3082
"edamron" <ed*****@spamcop.net> schrieb

The problem is, however, that sometimes the progressbar and the
treeview stop refreshing. This gives the appearance that the
program has hung. But in the end the treeview and progress bar
suddenly refresh and all of the CD volumes will pop into view.
There is no way for the code that increments the progressbar or the
code that updates the treeview can be skipped and have the nodes
still be populated. Can anyone tell me what may be going on? Below
is the sub where the nodes are being poplulated:

Private Sub DisplayVolumes()
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim v As Volume
Dim d As Directory
Dim t As Transcript
InitImageList()
vL = aM.GetVolumes()
For i = 1 To vL.Count
v = vL(i)
ProgressBar1.Maximum = v.Count
StatusBar1.Text = "Populating Nodes for CD-" & i
VolumeTreeView.Nodes.Add(New TreeNode(v.Name, 1, 2))
Dim n As TreeNode = VolumeTreeView.Nodes(i - 1)
For j = 1 To v.Count
ProgressBar1.Value = j
d = v.GetDirectory(j)
n.Nodes.Add(New TreeNode(d.Name, 3, 4))
Dim m As TreeNode = n.Nodes(j - 1)
For k = 1 To d.Count
t = d.GetTranscript(k)
m.Nodes.Add(New TreeNode(t.Name, 5, 5))
Next
Next
VolumeTreeView.Refresh()
Next
End Sub

This an annoying "feature" in WinXP. See 3rd paragraph:

http://msdn.microsoft.com/library/en...asp?frame=true

Work-around: In addition to calling progressbar1.refresh, call PeekMessage
API function:

Public Declare Function PeekMessage Lib "user32" Alias "PeekMessageA" _
(ByRef lpMsg As MSG, ByVal hwnd As IntPtr, _
ByVal wMsgFilterMin As Integer, ByVal wMsgFilterMax As Integer, _
ByVal wRemoveMsg As Integer) As Boolean
'...

PeekMessage(Nothing, Nothing, 0, 0, 0)

The designers probably thought that, if IN-put is not processed, there is no
OUT-put, too. Obviously this is wrong.
Armin

Mar 7 '06 #2
Thanks Armin. I think you're on to something. The compiler complains
about MSG not being defined. Do I need to import a particular
namespace or do I need to define a structure? If so which namespace or
what should the structure look like?

Thanks.

Mar 7 '06 #3
"edamron" <ed*****@spamcop.net> schrieb
Thanks Armin. I think you're on to something. The compiler
complains about MSG not being defined. Do I need to import a
particular namespace or do I need to define a structure? If so
which namespace or what should the structure look like?

Sorry, forgot the declaration:

<StructLayout(LayoutKind.Sequential)> _
Public Structure Point
Public x As Integer
Public y As Integer
End Structure

<StructLayout(LayoutKind.Sequential)> _
Public Structure MSG
Public hwnd As IntPtr
Public message As Integer
Public wParam As IntPtr
Public lParam As IntPtr
Public time As Integer
Public point As Point
End Structure

Armin
Mar 7 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mark Payne | last post by:
Gudday, I have an Access 2000 database which I am using as a phone directory of residents in the hostel where I work. The front end for this directory is a form with a text box (the search name...
0
by: Balázs Katona | last post by:
I have a form with a treeview. This application is MDI. In the treeview we show datas from database (not databinding). The application works in a client-server architecture. How can I achieve, if...
0
by: tlemcenvisit | last post by:
Refreshing a progressBar Hello I have a function which takes much execution time. I’d like to display its progress in a progressBar. For the moment I make like that: for(y=0;y<height;y++)...
4
by: pmcguire | last post by:
Rather than putting a progress bar on all of my forms to show progress during time consuming tasks, I made a form called frmProgress with 2 controls, a Label and a ProgressBar. Suppose I expose 1...
1
by: James L | last post by:
Hi, I have a treeview that has to be refreshed due to data changes. Is it possible to select the last node that they were viewing when the tree view was been populated once again? I have...
0
by: MichaelY | last post by:
I'm using the 2.0 TreeView, and thus far have been able to get most everything out of it I need (context menus on nodes, lazy loading, etc.). However, there is a scenario in which I'm not sure what...
0
by: drop | last post by:
Hi, I am using a Treeview and I'd like to know what is the best way to refresh the children of a specific node in the treeview. I already do that using full postback, but this sends back the...
1
by: echuck66 | last post by:
Hi, I have a Winforms 2.0 project that I'm working on that involves populating a treeview control from data contained in a fairly large dataset that has to be refreshed periodically. I have no...
2
by: =?Utf-8?B?QW1pciBUb2hpZGk=?= | last post by:
Hi I have a web page that has a TreeView on it. If I DONT'T expand the TreeView nodes, the auto refresh works nicely: my page gets refreshed every minute. As soon as I expand a node on the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.