Browse DevX
Sign up for e-mail newsletters from DevX


Creating Controls by Hand in the .NET Compact Framework

Using the visual drag-and-drop tools in Visual Studio is the easiest way to code controls but sometimes it's impractical, especially when working with applications meant for handheld devices. Learn how to hand-code new controls on the fly.

here will be times when you'll need to hand-code your .NET Compact Framework controls, without using the drag-and-drop feature of Visual Studio .NET. For example, you may not know how many controls to create during design time, and thus during runtime you need to create them explicitly using code.

A good example is the use of a context menu. The options in a context menu may be obtained from a Web service, and so you need to dynamically create the context menu when the program is running.

In this article, I will show you how to create controls dynamically and how to "wire" them up to event handlers.

I need to create a control for my handheld application on the fly at runtime, without going back to the visual environment.

Hand-code your controls directly into your project and then connect them with event handlers.

Thanks for your registration, follow us on our social networks to keep up-to-date