|
-
Jul 5th, 2005, 11:32 AM
#1
Thread Starter
Frenzied Member
progress bar [* Resovled *]
Hello,
I have a progress bar and i have the min set to 1 and the max set to 100. I want to be able to click on part of the progress bar and for the progress bar to go to the value that l click on in the progress bar.
For example if the progress is on 10, and l click on the bar in the area of about 80, then the progress will go up to that value of 80.
Many thanks in advance,
Steve
Last edited by steve_rm; Jul 7th, 2005 at 06:56 AM.
steve
-
Jul 5th, 2005, 03:38 PM
#2
Re: progress bar
rate it if it works
Code:
private int clickedX;
private void progressBar1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
clickedX = e.X;
}
private void progressBar1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
double val = (double)clickedX/progressBar1.Width;
int range = progressBar1.Maximum - progressBar1.Minimum;
progressBar1.Value = (int)(val * range);
}
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Jul 5th, 2005, 10:25 PM
#3
Re: progress bar
You should probably be using a TrackBar instead I think. Obviously it's up to you, but the ProgressBar doesn't accept user interaction easily because it's not supposed to be for that purpose.
-
Jul 7th, 2005, 06:52 AM
#4
Thread Starter
Frenzied Member
Re: progress bar
Hello,
Thanks for your reply. I found another way to do the same thing. Here is the code on vbcity.com.
Thanks
VB Code:
private void Form1_Load(object sender, System.EventArgs e)
{
this.progressBar1.MouseDown+=new MouseEventHandler(progressBar1_MouseDown);
this.progressBar1.MouseMove+=new MouseEventHandler(progressBar1_MouseMove);
}
private void progressBar1_MouseDown(object sender, MouseEventArgs e)
{
this.AdjustProgress(e);
}
private void progressBar1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
this.AdjustProgress(e);
}
}
private void AdjustProgress(MouseEventArgs e)
{
int x = e.X;
double d = ( ((double)x * (double)100.00) / (double)this.progressBar1.Width );
int value = Convert.ToInt32(System.Math.Ceiling((this.progressBar1.Maximum-this.progressBar1.Minimum)* d/100))+this.progressBar1.Minimum;
this.progressBar1.Value = System.Math.Max(this.progressBar1.Minimum, System.Math.Min(this.progressBar1.Maximum, value));
}
-
Jul 7th, 2005, 07:01 AM
#5
Re: progress bar [* Resovled *]
I take it we don't like the TrackBar then, that was purpose-built to provide this functionality.
-
Jul 7th, 2005, 03:15 PM
#6
Re: progress bar [* Resovled *]
same thing! wasting my time hehe
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|