C#Windows应用程序在创建一堆动态控件时停止 [英] C# Windows application stopping while creating bunch of dynamic controls

查看:70
本文介绍了C#Windows应用程序在创建一堆动态控件时停止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有ac #windows应用程序,在按钮点击事件中,我从数据库中获取记录并创建动态控件(即文本框)为每个记录并将其添加到面板。从数据库中我将​​获得200行,并且对于每行,我将动态地创建25个控件。

这意味着将在面板中创建200 * 25个控件。每次我点击按钮时,我都会清理并处理该面板的所有控件并重新创建控件并添加到面板。



现在我的问题是如果我首次单击该按钮,所有记录都已成功加载并使用动态控件(即文本框)创建。但是,如果我第二次再次点击该按钮,那么该程序正在敲响并要求关闭该应用程序。



我正在使用TableLayoutPanel来加载每一行在表格布局中,我正在为每列创建文本框以输入值。代码太重了,无法粘贴在这里。



它的问题而控件是第二次创建。



有人可以帮忙解决问题。



谢谢....

Hi,

I have a c# windows application and in the button click event I am getting the records from the database and creating dynamic controls (i.e., textboxes) for each record and adding them to a panel. From database I will get 200 rows and for each row I am creating 25 controls dyanmically.
That means 200 * 25 controls will be created in a panel. Each time I am clicking the button I was clearing and disposing all the controls of that panel and recreating the controls and adding to the panel.

Now my problem is if I click the button for the first time, all the records were loaded and created with dynamic controls (i.e, textboxes) successfully. But If I click the button again for the second time then the program is strucking and asking to close the application.

I am using TableLayoutPanel for loading each row and in the table layout pabel I am creating textboxes for each column to enter the values. The code was too heavy to paste here.

Its getting problem while the controls are creating for the second time.

Could anybody please help how to resolve the problem.

Thanks....

推荐答案

代码太重了,无法粘贴在这里

然后把它砍掉。

备份你的来源(这样你以后可以回到它)并砍掉与问题不完全相关的一切。运行。你还有这个问题吗?

是的:在这里发布一些简单的相关片段,我们可以看到你做了什么。

否:添加东西直到它失败。这至少会告诉你导致问题的原因,你可以调查或询问这个问题。



但是没有你的代码,这是我们唯一的建议能够提供......
"The code was too heavy to paste here"
Then cut it down.
Backup your source (so you can go back to it later) and chop out everything not exactly relevant to the problem. Run it. Do you still get the problem?
Yes: Post the bare-bones relevant fragment here and we can see what you do.
No: Add stuff back until it does fail. This will at least tell you what is causing the problem, and you can investigate or ask about that.

But without your code, that is about the only advice we are going to be able to provide...


这篇关于C#Windows应用程序在创建一堆动态控件时停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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