|By Xin Yan||
|July 29, 2005 01:45 AM EDT||
One of the new features in Visual Studio 2005 (VS2005) is easier custom control development for .NET Compact Framework. This article is about how to use Visual Studio 2005 to create custom control for .NET Compact Framework and provide design-time support.
Introduction to Custom Control
A Windows Forms custom control is a class that derives directly or indirectly from System.Windows.Forms.Control or System.Windows.Forms.
UserControl. Using custom control technology, developers can easily create powerful, reusable and redistributable Windows Forms controls.
There are three common custom control scenarios:
- Combine existing controls to author a composite control. In this case, the custom control should derive from System.Windows.Forms.UserControl.
- Extend an existing control to add to its functionality. In this case, the custom control should derive from the existing control, such as System.Windows.Forms.TextBox.
- Author a control that doesn’t depend on existing WinForm controls. In this case, the custom control should derive from System.Windows.Forms.Control.
Visual Studio 2005 fully supports creating custom controls in .NET Compact Framework. In addition, custom control developers can create a great design-time experience for custom control users. Design-time support makes it easier for developers to use custom controls in Visual Studio 2005 Smart Device projects.
Usually, building a custom control for .NET Compact Framework consists of two steps:
- Code the custom control
- Add design-time support
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:
- Can take user name and password input
- Provides animation functionality
- Can be easily used in Visual Studio 2005 designer
- Supports numeric input mode to help Smartphone users
To follow the article, you will need Visual Studio 2005 Beta 2 and Windows Mobile 5 Smartphone SDK.
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.
|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
SoftLayer operates a global cloud infrastructure platform built for Internet scale. With a global footprint of data centers and network points of presence, SoftLayer provides infrastructure as a service to leading-edge customers ranging from Web startups to global enterprises. SoftLayer's modular architecture, full-featured API, and sophisticated automation provide unparalleled performance and control. Its flexible unified platform seamlessly spans physical and virtual devices linked via a world...
May. 26, 2016 10:15 AM EDT Reads: 1,883
In his session at 18th Cloud Expo, Bruce Swann, Senior Product Marketing Manager at Adobe, will discuss how the Adobe Marketing Cloud can help marketers embrace opportunities for personalized, relevant and real-time customer engagement across offline (direct mail, point of sale, call center) and digital (email, website, SMS, mobile apps, social networks, connected objects). Bruce Swann has more than 15 years of experience working with digital marketing disciplines like web analytics, social med...
May. 26, 2016 10:00 AM EDT Reads: 1,225
SYS-CON Events announced today that EastBanc Technologies will exhibit at SYS-CON's 18th International Cloud Expo®, which will take place on June 7-9, 2016, at the Javits Center in New York City, NY. EastBanc Technologies has been working at the frontier of technology since 1999. Today, the firm provides full-lifecycle software development delivering flexible technology solutions that seamlessly integrate with existing systems – whether on premise or cloud. EastBanc Technologies partners with p...
May. 26, 2016 10:00 AM EDT Reads: 2,011
SYS-CON Events announced today that 24Notion has been named “Bronze Sponsor” of SYS-CON's 18th Cloud Expo, which will take place on June 7-9, 2016, at the Javits Center in New York, New York. 24Notion is full-service global creative digital marketing, technology and lifestyle agency that combines strategic ideas with customized tactical execution. With a broad understand of the art of traditional marketing, new media, communications and social influence, 24Notion uniquely understands how to con...
May. 26, 2016 10:00 AM EDT Reads: 1,740
With major technology companies and startups seriously embracing IoT strategies, now is the perfect time to attend @ThingsExpo 2016 in New York and Silicon Valley. Learn what is going on, contribute to the discussions, and ensure that your enterprise is as "IoT-Ready" as it can be! Internet of @ThingsExpo, taking place Nov 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with 17th Cloud Expo and will feature technical sessions from a rock star conference faculty ...
May. 26, 2016 09:45 AM EDT Reads: 2,420
SYS-CON Events announced today that Commvault, a global leader in enterprise data protection and information management, has been named “Bronze Sponsor” of SYS-CON's 18th International Cloud Expo, which will take place on June 7–9, 2016, at the Javits Center in New York City, NY, and the 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. Commvault is a leading provider of data protection and information management...
May. 26, 2016 08:45 AM EDT Reads: 2,890
Companies can harness IoT and predictive analytics to sustain business continuity; predict and manage site performance during emergencies; minimize expensive reactive maintenance; and forecast equipment and maintenance budgets and expenditures. Providing cost-effective, uninterrupted service is challenging, particularly for organizations with geographically dispersed operations.
May. 26, 2016 08:45 AM EDT Reads: 1,718
Join us at Cloud Expo | @ThingsExpo 2016 – June 7-9 at the Javits Center in New York City and November 1-3 at the Santa Clara Convention Center in Santa Clara, CA – and deliver your unique message in a way that is striking and unforgettable by taking advantage of SYS-CON's unmatched high-impact, result-driven event / media packages.
May. 26, 2016 08:15 AM EDT Reads: 2,104
SYS-CON Events announced today that BMC Software has been named "Siver Sponsor" of SYS-CON's 18th Cloud Expo, which will take place on June 7-9, 2015 at the Javits Center in New York, New York. BMC is a global leader in innovative software solutions that help businesses transform into digital enterprises for the ultimate competitive advantage. BMC Digital Enterprise Management is a set of innovative IT solutions designed to make digital business fast, seamless, and optimized from mainframe to mo...
May. 26, 2016 08:00 AM EDT Reads: 1,935
18th Cloud Expo, taking place June 7-9, 2016, at the Javits Center in New York City, NY, will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud strategy. Meanwhile, 94% of enterprises are using some...
May. 26, 2016 07:45 AM EDT Reads: 2,923
The IoTs will challenge the status quo of how IT and development organizations operate. Or will it? Certainly the fog layer of IoT requires special insights about data ontology, security and transactional integrity. But the developmental challenges are the same: People, Process and Platform. In his session at @ThingsExpo, Craig Sproule, CEO of Metavine, will demonstrate how to move beyond today's coding paradigm and share the must-have mindsets for removing complexity from the development proc...
May. 26, 2016 07:45 AM EDT Reads: 1,840
In his keynote at 18th Cloud Expo, Andrew Keys, Co-Founder of ConsenSys Enterprise, will provide an overview of the evolution of the Internet and the Database and the future of their combination – the Blockchain. Andrew Keys is Co-Founder of ConsenSys Enterprise. He comes to ConsenSys Enterprise with capital markets, technology and entrepreneurial experience. Previously, he worked for UBS investment bank in equities analysis. Later, he was responsible for the creation and distribution of life ...
May. 26, 2016 07:30 AM EDT Reads: 1,824
SYS-CON Events announced today that Tintri Inc., a leading producer of VM-aware storage (VAS) for virtualization and cloud environments, will exhibit at the 18th International CloudExpo®, which will take place on June 7-9, 2016, at the Javits Center in New York City, New York, and the 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA.
May. 26, 2016 07:15 AM EDT Reads: 2,160
Designing IoT applications is complex, but deploying them in a scalable fashion is even more complex. A scalable, API first IaaS cloud is a good start, but in order to understand the various components specific to deploying IoT applications, one needs to understand the architecture of these applications and figure out how to scale these components independently. In his session at @ThingsExpo, Nara Rajagopalan is CEO of Accelerite, will discuss the fundamental architecture of IoT applications, ...
May. 26, 2016 06:45 AM EDT Reads: 1,039
The IoT is changing the way enterprises conduct business. In his session at @ThingsExpo, Eric Hoffman, Vice President at EastBanc Technologies, discuss how businesses can gain an edge over competitors by empowering consumers to take control through IoT. We'll cite examples such as a Washington, D.C.-based sports club that leveraged IoT and the cloud to develop a comprehensive booking system. He'll also highlight how IoT can revitalize and restore outdated business models, making them profitable...
May. 26, 2016 06:30 AM EDT Reads: 2,659
SYS-CON Events announced today Object Management Group® has been named “Media Sponsor” of SYS-CON's 18th International Cloud Expo, which will take place on June 7–9, 2016, at the Javits Center in New York City, NY, and the 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA.
May. 26, 2016 06:15 AM EDT Reads: 2,298
SYS-CON Events announced today that Alert Logic, Inc., the leading provider of Security-as-a-Service solutions for the cloud, will exhibit at SYS-CON's 18th International Cloud Expo®, which will take place on June 7-9, 2016, at the Javits Center in New York City, NY. Alert Logic, Inc., provides Security-as-a-Service for on-premises, cloud, and hybrid infrastructures, delivering deep security insight and continuous protection for customers at a lower cost than traditional security solutions. Ful...
May. 26, 2016 05:45 AM EDT Reads: 2,658
SYS-CON Events announced today that MobiDev will exhibit at SYS-CON's 18th International Cloud Expo®, which will take place on June 7-9, 2016, at the Javits Center in New York City, NY. MobiDev is a software company that develops and delivers turn-key mobile apps, websites, web services, and complex software systems for startups and enterprises. Since 2009 it has grown from a small group of passionate engineers and business managers to a full-scale mobile software company with over 200 develope...
May. 26, 2016 05:15 AM EDT Reads: 2,441
WebRTC is bringing significant change to the communications landscape that will bridge the worlds of web and telephony, making the Internet the new standard for communications. Cloud9 took the road less traveled and used WebRTC to create a downloadable enterprise-grade communications platform that is changing the communication dynamic in the financial sector. In his session at @ThingsExpo, Leo Papadopoulos, CTO of Cloud9, will discuss the importance of WebRTC and how it enables companies to fo...
May. 26, 2016 05:00 AM EDT Reads: 2,467
SYS-CON Events announced today TechTarget has been named “Media Sponsor” of SYS-CON's 18th International Cloud Expo, which will take place on June 7–9, 2016, at the Javits Center in New York City, NY, and the 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. TechTarget is the Web’s leading destination for serious technology buyers researching and making enterprise technology decisions. Its extensive global networ...
May. 26, 2016 04:30 AM EDT Reads: 3,088