Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I have 4 images .i want to display all the 4 images one by oneusing progress bar on button clik event in window application.

Give some idea.
Posted
Comments
Sergey Alexandrovich Kryukov 27-Dec-12 1:02am    
What does it mean "using progress bar"? A progress bar does not help showing anything...
And you apparently suffer from "button sickness". "On button click..."
—SA

1 solution

using System;
using System.Windows.Forms;
using System.Drawing;
using System.Threading;

class Program
{
class ImageForm : Form
{
static void Main()
{
Application.EnableVisualStyles();
Application.Run(new ImageForm());
}
private ProgressBar pb;
public ImageForm()
{
Button button = new Button();
button.Text = "Load";
Controls.Add(button);
button.Click += new EventHandler(button_Click);
pb = new ProgressBar();
pb.Dock = DockStyle.Bottom;
pb.Style = ProgressBarStyle.Marquee;
pb.Visible = false;
Controls.Add(pb);
}

void button_Click(object sender, EventArgs e)
{
pb.Visible = true;
ThreadPool.QueueUserWorkItem(LoadImage);
}
private void LoadImage(object state)
{
Thread.Sleep(5000); // to make it look slower to demo
Image img = Image.FromFile(@"C:\WINDOWS\Coffee Bean.bmp");
Invoke((MethodInvoker) delegate {
BackgroundImage = img;
pb.Visible = false;
});
}
}
}

from here[^]
 
Share this answer
 
Comments
gmmanasbbsr 27-Dec-12 1:24am    
hi Sergey thanks for your response.but
i want 4 images should display one by one in picture box with progress bar.kindly give some sollution.
[no name] 27-Dec-12 1:26am    
No, we won't give you solution.. We can't work out for you like this.. You should try it by yourself.. If you got stuck somewhere, you can certainly come here.. But don't ask directly for code..
-Krunal R.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900