wrote: Trackback Added: Who is Technology’s Highest Paid CEO?; Who is Technology&...
Aug. 28, 2008 08:06 PM
|
YOUR FEEDBACK
|
TOP MICROSOFT .NET LINKS Feature Creating Custom Controls for Microsoft .NET Compact Framework in Visual Studio 2005
Learn to build the building blocks of mobile UI
By: Xin Yan
Jul. 29, 2005 01:45 AM
Usually, building a custom control for .NET Compact Framework consists of two steps:
In this article I am going to illustrate these steps by building a .NET Compact Framework custom control in Visual Studio 2005. The custom control is for sign-in forms and will look like Figure 1 on a Smartphone device. It is called SignInControl. Developers can utilize this custom control to implement a consistent sign-in experience for their apps. It has the following features:
Code the Custom Control SignInControl uses Label and TextBox controls to take user input, and PictureBox to display the animation. Thus it should derive from UserControl. The first step is to create a Visual Studio Smart Device project. Visual Studio 2005 has many Smart Device project types to choose from. In this example I am going to create a C# SmartPhone Windows Mobile 5 (code named Magneto) Control Library project called SignInControl (see Figure 2). ![]() After creating the project, rename the UserControl1.cs to SignInControl.cs. To protect my custom control assembly from tampering, I also signed my assembly with a strong name key file (right click on the project in the solution explorer, select “Properties,” and click on “Signing” tab). Now I am ready to implement my custom control. Go to the designer and drop two Label controls, two TextBox controls, one PictureBox control, and one Timer component. When doing this, notice the designer automatically displays snap-line to help aligning the controls. Set the Label controls to have proper text, and set the PasswordChar property of the password TextBox to “*.” Figure 3 is a screenshot of SignInControl in the designer. Two properties should be added to SignInControl to give developers access to the user name and password entered. Their implementation simply gets or sets the Text property value on the corresponding TextBox controls. Animation support is provided by the use of Timer and PictureBox. Add a Timer object to SignInControl, set its Interval property to 1000 (one second), and double click it to generate Timer.Tick event handler. The Timer object will raise an event every second. The PictureBox control’s image will be refreshed on each tick to achieve an animation effect. The images for animation are set in AnimationImages property using ImageList. An AnimationMode property is provided so that developers can turn animation on or off. After adding the above implementation, SignInControl.cs looks like Listing 1. YOUR FEEDBACK
MICROSOFT .NET LATEST STORIES
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK BREAKING NEWS FROM THE WIRES
|
||||||||||||||||||||||||||||||||||||