views:

39

answers:

2

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.

A: 

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.

Achilles
A: 

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.

Steven A. Lowe