473,847 Members | 2,440 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Progressbar

I am using VS 2005.
I read a file using streamreader.
I want to set the progressbar based on where I am in the file. How can I do
that ?
Thank you.

sr = New StreamReader(sF ileName)
line = sr.ReadLine
ProgressBar1.Ma ximum = 800 --how to set the maximum property without
reading the whole file first ?
ProgressBar1.Mi nimum = 0
ProgressBar1.St ep = 1
ProgressBar1.Va lue = 0
Do While line <Nothing
ProgressBar1.Pe rformStep()
:
line = sr.ReadLine
Loop
Apr 12 '07 #1
4 5799
On Apr 12, 4:13 pm, "fniles" <fni...@pfmail. comwrote:
I am using VS 2005.
I read a file using streamreader.
I want to set the progressbar based on where I am in the file. How can I do
that ?
Thank you.

sr = New StreamReader(sF ileName)
line = sr.ReadLine
ProgressBar1.Ma ximum = 800 --how to set the maximum property without
reading the whole file first ?
ProgressBar1.Mi nimum = 0
ProgressBar1.St ep = 1
ProgressBar1.Va lue = 0
Do While line <Nothing
ProgressBar1.Pe rformStep()
:
line = sr.ReadLine
Loop

Before entering your read loop grab the length of the file using
FileInfo:

Dim fi As FileInfo = New FileInfo(sFileN ame)
ProgressBar1.Ma ximum = fi.Length
ProgressBar1.Mi nimum = 0

Once minimum and Maximum are set then just then just keep track of
your bytes read count and each time through the loop set the progress
Value property

Do While ...
line = sr.ReadLine
....
....
....
ProgressBar1.Va lue = sr.BaseStream.P osition
Loop
Apr 12 '07 #2
Thank you.
So, I do not need to do ProgressBar1.Pe rformStep() anymore (instead replace
that with ProgressBar1.Va lue = sr.BaseStream.P osition) ?
"RickH" <pa******@windc restsoftware.co mwrote in message
news:11******** *************@l 77g2000hsb.goog legroups.com...
On Apr 12, 4:13 pm, "fniles" <fni...@pfmail. comwrote:
>I am using VS 2005.
I read a file using streamreader.
I want to set the progressbar based on where I am in the file. How can I
do
that ?
Thank you.

sr = New StreamReader(sF ileName)
line = sr.ReadLine
ProgressBar1.M aximum = 800 --how to set the maximum property without
reading the whole file first ?
ProgressBar1.M inimum = 0
ProgressBar1.S tep = 1
ProgressBar1.V alue = 0
Do While line <Nothing
ProgressBar1.Pe rformStep()
:
line = sr.ReadLine
Loop


Before entering your read loop grab the length of the file using
FileInfo:

Dim fi As FileInfo = New FileInfo(sFileN ame)
ProgressBar1.Ma ximum = fi.Length
ProgressBar1.Mi nimum = 0

Once minimum and Maximum are set then just then just keep track of
your bytes read count and each time through the loop set the progress
Value property

Do While ...
line = sr.ReadLine
...
...
...
ProgressBar1.Va lue = sr.BaseStream.P osition
Loop


Apr 13 '07 #3
On Apr 12, 8:57 am, "fniles" <fni...@pfmail. comwrote:
Thank you.
So, I do not need to do ProgressBar1.Pe rformStep() anymore (instead replace
that with ProgressBar1.Va lue = sr.BaseStream.P osition) ?

"RickH" <passp...@windc restsoftware.co mwrote in message

news:11******** *************@l 77g2000hsb.goog legroups.com...
On Apr 12, 4:13 pm, "fniles" <fni...@pfmail. comwrote:
I am using VS 2005.
I read a file using streamreader.
I want to set the progressbar based on where I am in the file. How can I
do
that ?
Thank you.
sr = New StreamReader(sF ileName)
line = sr.ReadLine
ProgressBar1.Ma ximum = 800 --how to set the maximum property without
reading the whole file first ?
ProgressBar1.Mi nimum = 0
ProgressBar1.St ep = 1
ProgressBar1.Va lue = 0
Do While line <Nothing
ProgressBar1.Pe rformStep()
:
line = sr.ReadLine
Loop
Before entering your read loop grab the length of the file using
FileInfo:
Dim fi As FileInfo = New FileInfo(sFileN ame)
ProgressBar1.Ma ximum = fi.Length
ProgressBar1.Mi nimum = 0
Once minimum and Maximum are set then just then just keep track of
your bytes read count and each time through the loop set the progress
Value property
Do While ...
line = sr.ReadLine
...
...
...
ProgressBar1.Va lue = sr.BaseStream.P osition
Loop- Hide quoted text -

- Show quoted text -
Yes, but remember that the current base stream position may be way
ahead of the current position your application code is at. This is
because the base stream reads the file in buffer blocks, but your app
is reading a line at a time. So what you can do is keep your own
counter of the total number of bytes you've read and use that value to
set the progress bar value.

like this:

dim myCounter as integer = 0
Do While ...
line = sr.ReadLine
myCounter += line.length
...
...
...
ProgressBar1.Va lue = myCounter
Loop
Apr 13 '07 #4
Thank you very much.

"RickH" <pa******@windc restsoftware.co mwrote in message
news:11******** **************@ n76g2000hsh.goo glegroups.com.. .
On Apr 12, 8:57 am, "fniles" <fni...@pfmail. comwrote:
>Thank you.
So, I do not need to do ProgressBar1.Pe rformStep() anymore (instead
replace
that with ProgressBar1.Va lue = sr.BaseStream.P osition) ?

"RickH" <passp...@windc restsoftware.co mwrote in message

news:11******* **************@ l77g2000hsb.goo glegroups.com.. .
On Apr 12, 4:13 pm, "fniles" <fni...@pfmail. comwrote:
I am using VS 2005.
I read a file using streamreader.
I want to set the progressbar based on where I am in the file. How can
I
do
that ?
Thank you.
>sr = New StreamReader(sF ileName)
line = sr.ReadLine
ProgressBar1.M aximum = 800 --how to set the maximum property
without
reading the whole file first ?
ProgressBar1.M inimum = 0
ProgressBar1.S tep = 1
ProgressBar1.V alue = 0
Do While line <Nothing
ProgressBar1.Pe rformStep()
:
line = sr.ReadLine
Loop
Before entering your read loop grab the length of the file using
FileInfo:
Dim fi As FileInfo = New FileInfo(sFileN ame)
ProgressBar1.Ma ximum = fi.Length
ProgressBar1.Mi nimum = 0
Once minimum and Maximum are set then just then just keep track of
your bytes read count and each time through the loop set the progress
Value property
Do While ...
line = sr.ReadLine
...
...
...
ProgressBar1.Va lue = sr.BaseStream.P osition
Loop- Hide quoted text -

- Show quoted text -

Yes, but remember that the current base stream position may be way
ahead of the current position your application code is at. This is
because the base stream reads the file in buffer blocks, but your app
is reading a line at a time. So what you can do is keep your own
counter of the total number of bytes you've read and use that value to
set the progress bar value.

like this:

dim myCounter as integer = 0
Do While ...
line = sr.ReadLine
myCounter += line.length
...
...
...
ProgressBar1.Va lue = myCounter
Loop


Apr 13 '07 #5

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

Similar topics

1
332
by: Maka Sili | last post by:
Using ProgressBar.Enabled = false does not dim the progress bar. There must be a way. I hope somebody could guide me. Thanks.
2
4826
by: Thomas Kehl | last post by:
Hi! Does anyone have a tipp for me where can I found (or how can I programm) a "progressbar" which has a gradient and the color go from the left side to right and back ... I should have a waiting-progressbar :-) Thanks Thomas
3
4367
by: Steve Teeples | last post by:
Is there a way for code from one class of C# to send a communication to a progressbar in another class to update the bar during runtime? -- Steve
2
6317
by: jez123456 | last post by:
Hi, thanks for the previous advice on progressbars with showing the percentage. I would now like to create a less clunky version. I.e at the moment my progressbar shows 7 separate steps. Some steps can take seconds to process, but others could take upto 10 minutes (leaving the users thinking nothing is happening!). Is there a way to show the progressbar smoothly increasing until the final step has finished instead of clunking it's way...
8
19645
by: needin4mation | last post by:
Please consider: foreach (ListViewItem item in listViewFiles.Items) { // Display the ProgressBar control. pBar1.Visible = true; // Set Minimum to 1 to represent the first file being copied. pBar1.Minimum = 1; // Set Maximum to the total number of files to copy. pBar1.Maximum = 4; //filenames.Length;
1
5430
by: Mehr H | last post by:
I've been trying to figure out how i can embed a Windows.Forms.ProgressBar in my webform (aspx) file. I have tried putting a Windows.Forms.ProgressBar as public on a regular winform designer form (form called ProgressForm) and the built the dll. Then I reference this new assembly from within my asp.net applicaiton and tried to access Windows.Forms.ProgressBar from within the ProgressForm but apparently it doesn't work. Because it won't...
3
4798
by: Mitchell Vincent | last post by:
In other programming languages I've been able to easily change the style of a progress bar between smooth and blocked. I find that is either really hidden or impossible in .NET. Am I missing something? I'm shocked that .NET doesn't have a style property for the progressbar control! -- - Mitchell Vincent - kBilling - An easy and affordable billing solution
1
696
by: nobody | last post by:
Hi I'm currently developing a Windows application. At the start of the application I load several tables into datatables in a dataset. I also use a progressbar to show the user how much percent of the total is already loaded. But I do this in a dirty way: I increment the progressbar with the same number after each table, but not all tables contain the same amount of data. I solved this with starting an other thread to increment the...
2
11133
by: =?Utf-8?B?QWFyb24=?= | last post by:
Since some controls such as the DataGridView take a long time to update themselves when performing certain tasks, I have added a StatusStrip with a ProgressBar on it. While I am updating the controls on the form, I want the ProgressBar to scroll in marquee mode. However, I cannot seem to get this to work. I set the StatusStripLabel to the text I want such as "Updating data..." and then set the ProgressBar's Style property to Marquee...
4
2513
by: sivamoorthy | last post by:
how to use a progressbar in a one cpp file but defined in another header file. the function in which i am using is a static member function. how to use the progressbar inside the function code: file name : flash.cpp void CFlasher::OnStartDownload (void *pDublicate) { bValueRet = DeviceIoControl (hHandle, \ (DWORD) IOCTL_SCUSBDFU_DETACH, NULL, \
0
9879
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9727
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10643
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10706
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10330
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9477
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5716
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4521
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4113
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.