| By Xin Yan | Article Rating: |
|
| July 29, 2005 01:45 AM EDT | Reads: |
116,037 |
To test this custom control, compile the project and add a SmartPhone Windows Mobile 5 WinForm application to the solution. When the form is opened, the SignInControl will be available in the toolbox and can be dropped to the form. If animation is needed, set AnimationMode property to On, add an ImageList to the form, and assign the ImageList to SignInControl’s AnimationImage property. Figure 5 is a screenshot of using SignInControl in designer.

Provide Design-Time Support
By now a functional custom control is created. It works on a Smartphone device, it appears in Visual Studio 2005 Toolbox and it can be dragged and dropped to the form designer. It looks pretty good but still misses some useful design-time features:
- Properties I added appear in the “Misc” category in the property browser (see Figure 5). Also they do not have descriptions associated with it.
- If user does not change properties such as UserName and Password in the designer, the following code will be generated inside InitializeComponent for the user:
this.signInControl1.Password = "";
this.signInControl1.UserName = "";
This is unnecessary because values of both properties are defaulted to the empty string. Ideally, the above code should not be generated.
These two are both design-time requirements. Most of the design-time support is specified in the form of design-time attributes. A design-time attribute describes how a control will behave at design-time. Some common design-time attributes are:
- BrowsableAttribute
- CategoryAttribute
- DescriptionAttribute
- EditorAttribute
- DesignerSerializationVisibility-Attribute
- And more …
You can find the definition of these attributes from MSDN. In the case of SignInControl, CategoryAttribute, and Descrip-tionAttribute need to be specified for each property to put it in the right category, and give it description.
I found the easiest approach to add design-time attributes is to use class designer. Open class designer as in Figure 4 and select desired property (for example UserName). Notice there is a “Custom Attribute” property in the property browser. Click on its editor button (the “…” button) and custom attribute editor will pop up. Type in the design-time attributes (see Figure 6). 
Click OK and repeat the same process for other properties. By now Category and Description design-time attributes are added. Take a look at the solution explorer. A new file named DesignTimeAttributes.xmta is added to the project with the following content supported (see Listing 2).
Published July 29, 2005 Reads 116,037
Copyright © 2005 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Xin Yan
Xin Yan has been a software design engineer at Microsoft for over 7 years. He works on Visual Studio developer tools platform team.
![]() |
Jay Dixit 10/11/07 07:07:23 AM EDT | |||
Hi truly a great article but i am new for it and just have some queries. Please help me for this. |
||||
![]() |
Jacques Herweijer 02/05/07 03:23:28 PM EST | |||
Hi great article, I completely understand the usercontrols now in a few minutes, its better than reading a book about it ! That however leaves me with 2 unanswered questions hope you can answer them. My first question is, How can I access the properties of the labels as soon as the usercontrol is used on a form, so I can change the Text property depending on the form I am using it on, or do I have to create a new usercontrol that inhertis your example for each label Text I want to use and drop that one on my form. I think this is very much work for just setting a label. And then my second one, How can I add controls to the usercontrol when I put it on my form ? For example if I wanted to add a button to the usercontrol when it is on my form but not in de usercontrol class itself (like a panel can contain controls) in Design-time ofcourse. Hope you can and be willing to give me an answer because I cannot find these answers anywhere. I think its hard to search the web when some functionallity is not available for Smart Device projects. Anyway Great article that give me a head start. |
||||
![]() |
.NET News Desk 07/28/05 02:49:36 PM EDT | |||
Creating Custom Controls for Microsoft .NET Compact Framework in Visual Studio 2005 |
||||
![]() |
.NET News Desk 07/28/05 02:49:30 PM EDT | |||
Creating Custom Controls for Microsoft .NET Compact Framework in Visual Studio 2005 |
||||
- Kindle 2 vs Nook
- Confessions of a Ulitzer Addict
- IBM Hardware Chief, Intel VC Exec Arrested in Insider Trading Scam
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- Ulitzer.com Named Exclusive "New Media" Sponsor of Cloud Computing Conference & Expo
- Infrastructure-as-a-Service Will Mature in 2010: Microsoft's David Chou
- Windows 7 – Microsoft’s First Step to the Cloud
- Cloud Expo and the End of Tech Recession
- Jill Tummler Singer, Deputy CIO of CIA, Keynotes at GovIT Expo
- Reality Check at the Cloud Computing Expo
- Visual Studio 2010 Is Cloud Friendly
- Fired SCO CEO Fires Back
- Kindle 2 vs Nook
- The Difference Between Web Hosting and Cloud Computing
- Ajax in RichFaces 3.3, JSF 2 and RichFaces 4
- Confessions of a Ulitzer Addict
- Wave on Ulitzer: Confessions of a Google Wave Fanboy
- IBM Hardware Chief, Intel VC Exec Arrested in Insider Trading Scam
- Cloud Computing Best Practices
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- Ulitzer.com Named Exclusive "New Media" Sponsor of Cloud Computing Conference & Expo
- Infrastructure-as-a-Service Will Mature in 2010: Microsoft's David Chou
- Eval JavaScript in a Global Context
- Windows 7 – Microsoft’s First Step to the Cloud
- Google Maps and ASP.NET
- Crystal Reports XI & How It Has Changed
- Converting VB6 to VB.NET, Part I
- Creating Controls for.NET Compact Framework in Visual Studio 2005
- Where Are RIA Technologies Headed in 2008?
- How to Write High-Performance C# Code
- AJAX World RIA Conference & Expo Kicks Off in New York City
- Implementing Tab Navigation with ASP.NET 2.0
- i-Technology Photo Exclusive: Bill Gates & Steve Jobs In "Nerds"
- .NET Archives: Getting Reacquainted with the Father of C#
- i-Technology Viewpoint: "SOA Sucks"
- Programmatically Posting Data to ASP .NET Web Applications






























