有没有什么“经验法则”? 关于动态创建表单控件?

发布于 2024-07-24 06:03:41 字数 304 浏览 6 评论 0原文

例如,假设正在开发一个新的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

差↓一点笑了 2024-07-31 06:03:42

我唯一需要动态创建控件的情况是:

  • 用户界面频繁更改(“个性化”),但底层数据/处理没有变化
  • 整个应用程序是数据驱动的,静态用户界面则不然 在 .NET WinForms 中,如果您在表单加载事件中创建控件(包括数据绑定),那么它可以很好地工作(例如,数据库记录规定了哪些字段和集是可见和可编辑的,并且这些数据经常更改)

the only time i've needed to create controls dynamically is when:

  • the user-interface changed frequently ("personalization") but the underlying data/processing did not
  • the entire application was data-driven to an extent that a static user interface was not possible (e.g. the database records dictated what fields and sets were visible and editable, and this data changed frequently)

in .NET WinForms, if you create the controls in the form-load event including databinding, it works quite well.

酷到爆炸 2024-07-31 06:03:41

这里是一篇非常好的文章,解释了在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文