C#Windows应用程序在创建一堆动态控件时停止

编程入门 行业动态 更新时间:2024-10-14 18:13:57
本文介绍了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应用程序在创建一堆动态控件时停止

本文发布于:2023-11-12 19:56:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1582388.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:控件   应用程序   动态   Windows

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!