As the Title states I'm trying to Display a Form that has a Listbox Docked to "Fill", theres no problem displaying the form but I want to Display the Items in the ListBox as each line is added to it (in this case the lines are added programatically through the code), much the same as you see when a program updates its own files or when a Setup programs shows you all the files that are extracted or added to the Install dir. There are over 5000+ lines so it takes a little bit of time to process the code that I'm trying to process, so I figured I would give the user a Display to show what was being done.

the problem is the process goes full head on til its completed all 5000+ lines then displays the lines in the Listbox. It does show all lines just not until the full code is processed. This defeats the purpose of having the Display, I wanted the User to be able to see what files are being processed, as they are being processed.

this is the code I am working with:

filepath = Application.StartupPath + "\\Images\\";

if (!Directory.Exists(filepath))
{
    Directory.CreateDirectory(filepath);
    MessageBox.Show("Images Directory Non-Existant, Creating new Folder. \nClick on File -> Add To Default Images, to add new images to the newly created default folder.");
}
else
{
    list = new ImageList();
    progressBar.Maximum = Directory.GetFiles(filepath).Length - 1;

    StatusUpdateDisplay update = new StatusUpdateDisplay();
    update.Show();

    statusLabel.Text = "Processing Image files, please stand by.";
    foreach (string file in Directory.GetFiles(filepath))
    {
        progressBar.Increment(1);
        statusLabel.Text = file;

        update.listBox1.Items.Add(statusLabel.Text);

        //update.listBox1.Show();
        //update.Show();

        Bitmap map = new Bitmap(Image.FromFile(file));
        list.Images.Add(file.ToString(), map);
    }
    update.Show();
    statusLabel.Text = "Files processing completed";
    progressBar.Value = 0;
}

The "StatusUpdateDisplay" is the Form that has the ListBox in it.

I've added the FileName and FilePath to the ListBox with this code: update.listBox1.Items.Add(statusLabel.Text); and once all 5000+ lines are added it will display them all, but I want it to update the ListBox Display each time a line is added.

Is there some way to do this?

I am just a hobbyist when it comes to software programming, I dont work in the IT field and I'm not a student, everything I learn I learn from getting out and looking through the Internet, I've gotten preaty good at googling. But in this case either I dont know what to google for or I'm just not finding anything. If anyone can help me here I sure do appreciate it.

Mark Sweetman aka roadmaster

Edited 6 Years Ago by roadmaster: n/a

Welcome here at Daniweb, roadmaster!
Using the Refresh() method of your listbox, should do the trick.

Edited 6 Years Ago by ddanbe: n/a

Welcome here at Daniweb, roadmaster!
Using the Refresh() method of your listbox, should do the trick.

thanks that did it...

roadmaster

This question has already been answered. Start a new discussion instead.