|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
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 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 solutions, helping companies worldwide activate their data to drive more value and business insight and to transform moder...
Sep. 26, 2016 02:45 PM EDT Reads: 2,587
Fifty billion connected devices and still no winning protocols standards. HTTP, WebSockets, MQTT, and CoAP seem to be leading in the IoT protocol race at the moment but many more protocols are getting introduced on a regular basis. Each protocol has its pros and cons depending on the nature of the communications. Does there really need to be only one protocol to rule them all? Of course not. In his session at @ThingsExpo, Chris Matthieu, co-founder and CTO of Octoblu, walk you through how Oct...
Sep. 26, 2016 02:15 PM EDT Reads: 2,076
The Internet of Things can drive efficiency for airlines and airports. In their session at @ThingsExpo, Shyam Varan Nath, Principal Architect with GE, and Sudip Majumder, senior director of development at Oracle, will discuss the technical details of the connected airline baggage and related social media solutions. These IoT applications will enhance travelers' journey experience and drive efficiency for the airlines and the airports. The session will include a working demo and a technical d...
Sep. 26, 2016 02:00 PM EDT Reads: 1,715
There is little doubt that Big Data solutions will have an increasing role in the Enterprise IT mainstream over time. Big Data at Cloud Expo - to be held November 1-3, 2016, at the Santa Clara Convention Center in Santa Clara, CA - has announced its Call for Papers is open. Cloud computing is being adopted in one form or another by 94% of enterprises today. Tens of billions of new devices are being connected to The Internet of Things. And Big Data is driving this bus. An exponential increase is...
Sep. 26, 2016 01:45 PM EDT Reads: 2,560
Digital innovation is the next big wave of business transformation based on digital technologies of which IoT and Big Data are key components, For example: Business boundary innovation is a challenge to excavate third-party business value using IoT and BigData, like Nest Business structure innovation may propose re-building business structure from scratch, as Uber does in the taxicab industry The social model innovation is also a big challenge to the new social architecture with the design fr...
Sep. 26, 2016 01:30 PM EDT Reads: 1,166
In his keynote at 18th Cloud Expo, Andrew Keys, Co-Founder of ConsenSys Enterprise, provided 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 sett...
Sep. 26, 2016 01:15 PM EDT Reads: 3,308
The many IoT deployments around the world are busy integrating smart devices and sensors into their enterprise IT infrastructures. Yet all of this technology – and there are an amazing number of choices – is of no use without the software to gather, communicate, and analyze the new data flows. Without software, there is no IT. In this power panel at @ThingsExpo, moderated by Conference Chair Roger Strukhoff, panelists will look at the protocols that communicate data and the emerging data analy...
Sep. 26, 2016 01:00 PM EDT Reads: 1,616
DevOps at Cloud Expo, taking place Nov 1-3, 2016, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with 19th Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The widespread success of cloud computing is driving the DevOps revolution in enterprise IT. Now as never before, development teams must communicate and collaborate in a dynamic, 24/7/365 environment. There is no time to wait for long dev...
Sep. 26, 2016 12:45 PM EDT Reads: 3,414
SYS-CON Events announced today that China Unicom will exhibit at the 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. China United Network Communications Group Co. Ltd ("China Unicom") was officially established in 2009 on the basis of the merger of former China Netcom and former China Unicom. China Unicom mainly operates a full range of telecommunications services including mobile broadband (GSM, WCDMA, LTE F...
Sep. 26, 2016 12:45 PM EDT Reads: 1,738
Data is an unusual currency; it is not restricted by the same transactional limitations as money or people. In fact, the more that you leverage your data across multiple business use cases, the more valuable it becomes to the organization. And the same can be said about the organization’s analytics. In his session at 19th Cloud Expo, Bill Schmarzo, CTO for the Big Data Practice at EMC, will introduce a methodology for capturing, enriching and sharing data (and analytics) across the organizati...
Sep. 26, 2016 12:15 PM EDT Reads: 1,671
SYS-CON Events announced today that ReadyTalk, a leading provider of online conferencing and webinar services, has been named Vendor Presentation Sponsor at the 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. ReadyTalk delivers audio and web conferencing services that inspire collaboration and enable the Future of Work for today’s increasingly digital and mobile workforce. By combining intuitive, innovative tec...
Sep. 26, 2016 12:00 PM EDT Reads: 2,797
The Transparent Cloud-computing Consortium (abbreviation: T-Cloud Consortium) will conduct research activities into changes in the computing model as a result of collaboration between "device" and "cloud" and the creation of new value and markets through organic data processing High speed and high quality networks, and dramatic improvements in computer processing capabilities, have greatly changed the nature of applications and made the storing and processing of data on the network commonplace.
Sep. 26, 2016 11:30 AM EDT Reads: 1,002
SYS-CON Events announced today the Enterprise IoT Bootcamp, being held November 1-2, 2016, in conjunction with 19th Cloud Expo | @ThingsExpo at the Santa Clara Convention Center in Santa Clara, CA. Combined with real-world scenarios and use cases, the Enterprise IoT Bootcamp is not just based on presentations but with hands-on demos and detailed walkthroughs. We will introduce you to a variety of real world use cases prototyped using Arduino, Raspberry Pi, BeagleBone, Spark, and Intel Edison. Y...
Sep. 26, 2016 11:15 AM EDT Reads: 2,874
Major trends and emerging technologies – from virtual reality and IoT, to Big Data and algorithms – are helping organizations innovate in the digital era. However, to create real business value, IT must think beyond the ‘what’ of digital transformation to the ‘how’ to harness emerging trends, innovation and disruption. Architecture is the key that underpins and ties all these efforts together. In the digital age, it’s important to invest in architecture, extend the enterprise footprint to the cl...
Sep. 26, 2016 11:06 AM EDT Reads: 190
Video experiences should be unique and exciting! But that doesn’t mean you need to patch all the pieces yourself. Users demand rich and engaging experiences and new ways to connect with you. But creating robust video applications at scale can be complicated, time-consuming and expensive. In his session at @ThingsExpo, Zohar Babin, Vice President of Platform, Ecosystem and Community at Kaltura, will discuss how VPaaS enables you to move fast, creating scalable video experiences that reach your...
Sep. 26, 2016 11:00 AM EDT Reads: 1,001
SYS-CON Events announced today that SoftLayer, an IBM Company, has been named “Gold 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. SoftLayer, an IBM Company, provides cloud infrastructure as a service from a growing number of data centers and network points of presence around the world. SoftLayer’s customers range from Web startups to global enterprises.
Sep. 26, 2016 10:30 AM EDT Reads: 907
SYS-CON Events announced today that Bsquare has been named “Silver Sponsor” of SYS-CON's @ThingsExpo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. For more than two decades, Bsquare has helped its customers extract business value from a broad array of physical assets by making them intelligent, connecting them, and using the data they generate to optimize business processes.
Sep. 26, 2016 10:00 AM EDT Reads: 2,701
Big Data has been changing the world. IoT fuels the further transformation recently. How are Big Data and IoT related? In his session at @BigDataExpo, Tony Shan, a renowned visionary and thought leader, will explore the interplay of Big Data and IoT. He will anatomize Big Data and IoT separately in terms of what, which, why, where, when, who, how and how much. He will then analyze the relationship between IoT and Big Data, specifically the drilldown of how the 4Vs of Big Data (Volume, Variety,...
Sep. 26, 2016 10:00 AM EDT Reads: 1,007
Cognitive Computing is becoming the foundation for a new generation of solutions that have the potential to transform business. Unlike traditional approaches to building solutions, a cognitive computing approach allows the data to help determine the way applications are designed. This contrasts with conventional software development that begins with defining logic based on the current way a business operates. In her session at 18th Cloud Expo, Judith S. Hurwitz, President and CEO of Hurwitz & ...
Sep. 26, 2016 09:45 AM EDT Reads: 2,880
WebRTC adoption has generated a wave of creative uses of communications and collaboration through websites, sales apps, customer care and business applications. As WebRTC has become more mainstream it has evolved to use cases beyond the original peer-to-peer case, which has led to a repeating requirement for interoperability with existing infrastructures. In his session at @ThingsExpo, Graham Holt, Executive Vice President of Daitan Group, will cover implementation examples that have enabled ea...
Sep. 26, 2016 09:00 AM EDT Reads: 1,532