有没有什么“经验法则”? 关于动态创建表单控件?
例如,假设正在开发一个新的 Windows From 应用程序,假设有 25 个不同的屏幕,每个屏幕上有 5-10 个控件......
显然,所有必要的列表框、对话框、列表视图、数据集等......可以在创建原始屏幕时创建(例如使用工具箱中的放置和拖动)。
那么在什么时候,出于什么原因,会出现动态创建列表视图或下拉菜单的代码。
这是否只是一种消耗,随着时间的推移,程序员认为这样做比修改原始屏幕更容易?
或者是否有更好的理由动态创建一些最初设计的屏幕上从未存在的控件?
谢谢 - 希望这是清楚的。
For example, suppose a new Windows From application were being developed with lets say 25 different screens each of which had say 5-10 controls on them.....
Obviously all of the necessary listboxes, dialog boxes, listviews, datasets etc.. could have been created when the original screens were created (say using drop & drag from the toolbox).
At what point then, and for what reason, does code come along that dynamically creates a listviews or a dropdown menus.
Is it just an attrition kind of thing, where over time the programmers decide it is easier do to this then to modify the original screens?
Or are there better reasons for creating some controls dynamically that never existed on the originally designed screens?
Thanks - hope that was clear.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我唯一需要动态创建控件的情况是:
。
the only time i've needed to create controls dynamically is when:
in .NET WinForms, if you create the controls in the form-load event including databinding, it works quite well.
这里是一篇非常好的文章,解释了在 ASP.NET 上下文中使用动态控件以及它何时适用。 我相信同样的例子也适用。 通常,在运行时插入控件使您可以灵活地根据用户需要输入的数据以不同的方式呈现 UI。 希望这有帮助。
Here is a really good article explaining using dynamic controls in the context of ASP.NET and when it would be applicable. The same examples are applicable I believe. Generally insert controls at run-time gives you the flexibility to render the UI differently depending on the data that needs to be entered by the user. Hopes this helps.