Chapter 11: Dynamic User Interface
Overview
One of the most common questions in any Windows programming language is how to programmatically add a control to a form at runtime. The answer depends on the programming framework, and ranges from simple to complex, especially if the programmer needs to add a licensed ActiveX control or handle the events of the newly created control..NET erases the distinction between design-time and runtime control programming. In .NET programming, every control is created through code. When you add a control to a form and configure its properties using the design editor, Visual Studio .NET generates the appropriate code and adds it to a collapsed region of your Form class. By studying this region of your code, you can quickly learn how to create and add any control you need at runtime.Of course, creating a dynamic user interface is about much more than defining a control class at runtime. It's also a philosophy that breaks free of the shackles of visual design tools and allows you to generate interfaces based on database records, user preferences, or localization needs. This chapter examines some innovative techniques you can use to dynamically generate a user interface. It starts with the mandatory button generators, and moves to drawing tools, document applications, and the question of localization. It even considers how you can create a custom form layout engine.