Application.Run(new Form1())错误,当它包含太多控件时? [英] Application.Run(new Form1()) error ,when it contain too many controls?

查看:301
本文介绍了Application.Run(new Form1())错误,当它包含太多控件时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        for (int i = 0; i < 9962; ++i)
        {
            Button temp = new Button();
            temp.Location = new Point(100, 100);
            this.panel1.Controls.Add(temp);
            temp.Show();
        }

    }
}





当数量为9962时,没关系。



Application.Run(新Form1()) 当num大于9962时抛出异常。



为什么?



When the num is 9962 ,it's ok.

Application.Run(new Form1()) throw an exception when the num is larger than 9962.

why?

推荐答案

为什么你想要做那样的事情?

正如ThePhantomUpvoter所说,你添加了太多的控件,并且windows无法创建那么多按钮。

想一想。如果每个按钮都是默认大小,则需要显示75x23 * 9962像素。

这是一个4145像素宽的屏幕,高4145像素。



即使你的规范要求它,这也是一个愚蠢的想法。你如何期望你的用户在一个大小的屏幕上找到合适的按钮,假设他有八个正常的1080 x 1920屏幕坐在那里显示它们......如果他还要滚动,那就更糟了!



找到一个更好的解决方案:这个不会起作用......
Why the heck would you want to do something like that?
As ThePhantomUpvoter says, you are adding too many controls, and windows is not capable of creating that many buttons.
Think about it for a moment. If each button is the default size, then that is 75x23*9962 pixels you need to display them.
That's a screen 4145 pixels wide, by 4145 pixels high.

Even if your specification demands it, it's a stupid idea. How do you expect your user to find the right button in a screen that size, assuming he has eight normal 1080 x 1920 screens sitting there to display them... If he has to scroll as well, that's even worse!

Find a better solution: this one is just not going to work...


这篇关于Application.Run(new Form1())错误,当它包含太多控件时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆