Click here to Skip to main content
15,883,883 members
Articles / Desktop Programming / Windows Forms
Article

Build lookup control using visual studio 2005

Rate me:
Please Sign up or sign in to vote.
2.29/5 (11 votes)
22 Oct 20051 min read 43.4K   1.1K   20   2
Custom editors in building user controls

Sample Image - LookupScreenShot.jpg

Introduction

In this article I tried to illustrate how it's easy to develop custom user control with different types of property editors and how to make custom data binding property in visual studio 2005 beta and visual c#

<o:p> 

While building this control, I tried to be as close as possible to the MVC (Model / View / Controller) pattern

Control Model

Model

All the selection statement are based on the INFORMATION_SCHEMA system view, so that I can gain full compliance with Sql Server 2000 and Sql Server 2005

 

Drop Down Editors

 

We only need to specify UITypeEditorEditStyle.DropDown in the edit style override

 

I had a problem that I needed to access another property of the user control ( The Sql Connection already defined by developer) , I found a very handy reference which is context.Instance which I got it in edit value override , that I casted to my user control class 

Modal Dialog Editor

Just specify UITypeEditorEditStyle.Modal in the edit style override , the control illustrates that you can easily embed any form as your dialog in Visual Studio

 

Usage

 

Developer should specify the SqlConnection property , then the table name , optionally he/she has to specify the table schema ( used heavily in Adventure Works sample database that shipped with Sql Server 2005 Beta ) , finally he has to select the columns that appear to the users in the lookup dialog

 

Achnowledgment

 

Thanks to the article "Creating Custom Controls-Providing Design Time Support 1 " By Kodanda Pani as it was a good starting point for me

 

History

 

Initial version on 22-10-2005

 

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Egypt Egypt
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMy vote of 2 Pin
span23728-Mar-10 12:17
span23728-Mar-10 12:17 
GeneralLookup control Pin
markop20-Oct-07 23:46
markop20-Oct-07 23:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.