How to make my application as fast as Windows Explorer for rendering files

I have a folder with a lot of files inside it. I want each of my files to display as a button. And when I click on the button, something will happen.

 private void Form1_Load(object sender, EventArgs e)
    {
        int x = 10; 
        int y = 10;

        /// Process the list of files found in the directory.
        string[] fileEntries = Directory.GetFiles(@"c:\lotsofDocs");
        foreach (string fileName in fileEntries)
        {
            // do something with fileName
            Button newbotton = new Button();
            newbotton.AutoSize = true;
            newbotton.Text = fileName;
            panel1.Controls.Add(newbotton);
            newbotton.Location = new Point(x, y);
            x += 150;
            if (x == 760)
            {
                y += 50;
                x = 10;
            }
        }

As you can see, there is nothing crazy in the code. I have a panel on the form, and I set the auto scroll on the panel to true and auto size to false. This causes the form to support size and buttons (some of them anyway) to get visualization from the form, and I can scroll them down.

So far so good.

If I have 100 or 200 files, everything is fine, if I have 1932 files, it takes about 10 seconds to display all the buttons.

# custom control, , , , .

: ? Windows, . Windows? - .

+5
4

. , 20 , 20 . , 20 .

, ( ).

, . , " ".

DIY, . , Tree, List Grid Telerik . Winforms

+5
+2

? , , ( , ), . , , . , Add , .

0

, /, / . panel1 . , , .

, Win32 WinForms. Window System , , .

. 2000 5 x 400? . . , 150 ? , "150" ".15 "?


? , , /, , , . " ", , , , . , LitView . (, ), , .

You can also display buttons as HTML links and display them inside a browser control. This is not necessarily faster, but HTML is progressing gradually, I can use this list while you are still eating items.

0
source

All Articles