Content by Category
.NET 1.x
.NET 2.0
.NET 3.0
.NET 3.5
.NET 4.0
.NET 4.5
.NET Assemblies
.NET Framework
.NET Getting Started
Accessibility
ADO.NET
Advertorials
Agile Development
AJAX
Amazon Web Services
Analysis Services
Android
Architecture
Arduino
ASP .NET Web API
ASP.NET
ASP.NET MVC
ASP.NET WebForms
Azure
B2B (Business Integration)
BDD
Big Data
Bing
BizTalk
Book Excerpts
Build and Deploy
Business Intelligence
C#
C++
ClickOnce
Cloud Computing
Code Contracts
CODE Framework Info - non Technical
CODE on the Road!
COM+
Community
Conferences
Continuous Integration
Crystal Reports
CSLA.NET
CSS
Data
Debugger
Design Patterns
Development Process
Display Technologies
Distributed Computing
Document Database
DotNetNuke
DSL
Dynamic Languages
Dynamic Programming
Editorials
Enterprise Services ("COM+")
Entity Framework
Events
Expression Blend
F#
Fox to Fox
Frameworks
Functional Programming
Git
Graphics
HTML 5
Internet Explorer 8.0
Interviews
IOS
iPhone
Iron Ruby
Java
Java Script
JavaScript
jQuery
JSON
Lightswitch
LINQ
Linux
LUA
Mac OS X
MDX
Messaging
Metro
Microsoft Application Blocks
Microsoft Business Rules Framework
Microsoft Dynamics
Microsoft Expression
Microsoft Office
Mobile Development
Mobile PC
Mono
MsBuild
MVVM
MySQL
Network
NHibernate
node.js
NOSQL
Nuget
Object Oriented Development
Objective C
Odata
OLAP
Open Source
Opinion
Opinions
Oracle
ORM
Other Languages
Parallel Programming
Patterns
PHP
Podcasts
Post Mortem
PowerPoint
Print/Output
Prism
Product News
Product Reviews
Project Management
Prolog
Python
Q&A
Rails
Rake
Razor
Reporting Services
REST
RIA Services
Ruby
Ruby on Rails
Scheme
Search
Security
Services
SharePoint
SignalR
Silverlight
SOA
Social Networks
Software & Law
Software Business
Source Control
Speech-Enabled Applications
SQL Server
SQL Server 2000
SQL Server 2005
SQL Server 2008
SQL Server 2012
SQL Server CE/AnyWhere/Mobile/Compact
SSIS
Subversion
Sync Framework
Tablet PC
TDD
Team System
Techniques
Testing and Quality Control
TFS
Tips
TypeScript
UI Design
UML
User Groups
VB Script
VB.NET
Version Control
VFP and .NET
VFP and SQL Server
Virtual Earth
Vista
Visual Basic
Visual Basic 6 (and older)
Visual FoxPro
Visual Studio .NET
Visual Studio 11
Visual Studio 2005
Visual Studio 2008
Visual Studio 2010
Visual Studio 2011
Visual Studio 2012
Visual Studio Tools for Office
VSX
WCF
Web Development (general)
Web Services
WebMatrix
WF
Whitepapers
Windows 7
Windows 8
Windows Azure
Windows Live
Windows Phone 7
Windows Phone SDK
Windows Server
Windows Vista
WinForms
WinRT
Workflow
WPF
XAML
Xiine Documentation
XML
XNA
XSLT



LearnNow


XAMALOT
 


SSWUG


Reader rating:
Click here to read 3 comments about this article.
Article source: CoDe (2007 - Jul/Aug)


Article Pages:  1  2 3 4 5 - Next >


Adding Smart Tags to Windows Forms Controls

One new features in Visual Studio 2005 is the support for smart tags. A smart tag is a panel that displays next to a control and contains a list of commonly used properties.

The DataGridView control in Windows Forms has a smart tag (with the header “DataGridView Tasks”) showing a list of commonly used properties (Figure 1). In .NET 2.0, developers can add the smart tag feature to their custom/user controls. In this article, I will walk you through a real world project that I have done that shows how to add your own smart tags to controls.

Click for a larger version of this image.

Figure 1: Examining the smart tag of the DataGridView control.

"
You can use the DaysInMonth() method from the Date class to find out the number of days in a particular month and year.
"

I’ll show you how to create a custom date control. My client specifically wanted an easy way to enter dates without using the mouse to select a date. In addition, they wanted the ability to customize the format in which the date is displayed-either numerically or alphabetically-to represent the month. On the surface this task looks easy to solve-simply add a couple of TextBox controls to the form and configure them to display day, month, and year accordingly. However, the client had numerous forms requiring date entry, and thus I decided that a better solution was to create a user control that aggregates all the TextBox controls into one single control. In the first part of this article I’ll show you how to create the user control and in the second part of the article I’ll show you how to add smart tag support to the user control.

Developing the User Control

Using Visual Studio 2005, create a Windows Application project named SmartTag. This Windows application will act as a host for the user control that I’ll show you how to build in this article.

Now, add a new Windows Control Library project to the existing solution. In Solution Explorer, right-click the SmartTag solution and select Add > New Project…. Select the Windows Control Library template and name the project CustomDateControl. Click OK. The left of Figure 2 shows the default design surface of the user control (default name is UserControl1.vb). Populate the design surface with three ComboBox controls shown on the right of Figure 2.

Click for a larger version of this image.

Figure 2: The design surface of the user control and the controls added to it.

Set the properties of the three ComboBox controls with the values shown in Table 1. The first two ComboBox controls will display either the day or month (depending on the user’s configuration) while the third ComboBox control will display the year. Users can either click the ComboBox control to select a date or simply type the date using the keyboard.

Programming the User Control

With the design of the user control completed, you can now start the coding. Switch to the code behind of UserControl1.vb and add the following namespace:

Imports System.ComponentModel

The System.ComponentModel namespace provides classes that are used to implement the run-time and design-time behavior of components and controls. In this case, I will be adding attributes to my control class and its properties to customize its behavior. You will see its uses shortly.

Next, declare the Formats and Months enumeration to represent the format and months, respectively:

Public Enum Formats
    DDMMYYYY  '---e.g. 29 02 2006---
    DDMmmYYYY '---e.g. 12 Jan 2006---
    MMDDYYYY  '---e.g. 02 25 2006---
    MmmDDYYYY '---e.g. Jan 15 2006---
End Enum

Public Enum Months
    Jan = 1
    Feb = 2
    Mar = 3
    Apr = 4
    May = 5
    Jun = 6
    Jul = 7
    Aug = 8
    Sep = 9
    Oct = 10
    Nov = 11
    Dec = 12
End Enum
&

By: Wei-Meng Lee

Wei-Meng Lee is a technologist and founder of Developer Learning Solutions (http://www.learn2develop.net), a technology company specializing in hands-on training on the latest Microsoft technologies.

Wei-Meng speaks regularly at international conferences and is the author of ASP.NET 2.0: A Developer’s Notebook and Visual Basic 2005 Jumpstart (both from O'Reilly Media, Inc).

Wei-Meng is currently a Microsoft Device Application Development MVP.

Contact Wei-Meng at weimenglee@learn2develop.net.

Fast Facts

The properties of a user control must be set through a proxy property (which, in this case, is returned by the GetPropertyByName() function); you cannot set the property of a control directly.



ControlPropertyValue
UserControl1Size230,32
cbbField1AutoCompleteModeSuggestAppend
cbbField1AutoCompleteSourceListItems
cbbField1DropDownStyleDropDownList
cbbField2AutoCompleteModeSuggestAppend
cbbField2AutoCompleteSourceListItems
cbbField2DropDownStyleDropDownList
cbbYearAutoCompleteModeSuggestAppend
cbbYearAutoCompleteSourceListItems
cbbYearDropDownStyleDropDownList


Article Pages:  1  2 3 4 5 - Next Page: 'Defining the Member Variables' >>

Page 1: Adding Smart Tags to Windows Forms Controls
Page 2: Defining the Member Variables
Page 3: Servicing the Events
Page 4: Adding Smart Tags
Page 5: Viewing the Smart Tag

How would you rate the quality of this article?
1 2 3 4 5
Poor      Outstanding

Tell us why you rated the content this way. (optional)

Average rating:
3.5 out of 5

21 people have rated this article.

Instantly Search Terabytes Of Text
“Lightning Fast”
– Redmond Mag
“Covers all data
sources” – eWeek
25+ fielded & full-text search options
dtSearch’s own document filters highlight hits in popular file types
Web Spider supports static & dynamic data
APIs for .NET, Java, C++, SQL, etc.
Win / Linux (64-bit & 32-bit)
www.dtSearch.com
 

      Sharepoint TechCon

 

SSWUG