Click here to Skip to main content
13,737,883 members
Click here to Skip to main content
Add your own
alternative version


59 bookmarked
Posted 25 Feb 2002
Licenced CPOL

URLComboBox : A window forms control for displaying URL's

, 25 Feb 2002
Rate this:
Please Sign up or sign in to vote.
A window forms control for displaying URL's similar to URL combo in IE.
<!-- Download Links --> <!-- Article image -->

Sample Image - URLCombo.gif

<!-- Add the rest of your HTML here -->


URL combo box is an easy to use control for displaying URLs. I had to devlop this when I wrote a rich client interface for a web service.

Here are some features of the control :-

  • Autocomplete support like that in IE.  

  • Automatic management of MRU list. The control automatically fills the combo list from a specific registry key (specified as a property) and also adds any URL entered by the user which is not already in the registry.

Using the control

It is very simple to use the control.

  1. Add it to the VS.NET tool box.

  2. Place it on any form.

  3. Set the AutoComplete options by specifying the Flags property. This controls what is displayed in the autocomplete popup list. For example in the image shown below the Flags property is set so that the URL history, most recently typed URLs and the file system is included in the autocomplete list. (The various flags are documented in the C# xml documentation and correspond to the flags that can be specified to SHAutoComplete function).

  4. Optionally the properties MRUKeyHive and MRUKey can be specified. MRUKeyHive can be MRUKeyHive.LocalMachine or MRUKeyHive.CurrentUser, this indicates the root registry key (HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER) to use. MRUKey is a string value that specifies the path of sub key under this key. The control looks for value names of the form urlXXX under this key (where XXX is a number e.g url1, url2) and uses the data from these registry values to fill the list box. This is the same way as IE manages the list of MRU URLs. The control also updates the registry key based on any new URL typed.

    The default values of these properties are set to the registry key which IE uses for storing its most recently used URLs.

That's all that needs to be done to use this control. In fact the demo VB app which is an internet browser has only one line of user written code. Everything else like resizing and layout of controls is managed by the window forms framework.


The implementation is pretty simple. The controls CreateHandle function is overloaded. In this function the handle of the edit control is obtained by calling unamanaged GetComboBoxInfo function. The handle thus obtained is passed to SHAutoComplete function again through PInvoke. The MRU list is managed by using the convenient Microsoft.Win32.Registry and Microsoft.Win32.RegistryKey classes. The code contains the C# doc comments wherever necessary.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Rama Krishna Vavilala
United States United States
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralDetecting when the selection is complete Pin
nagarsoft2-May-05 22:09
membernagarsoft2-May-05 22:09 
Generalusing the tab key Pin
Soliant30-Sep-04 9:24
memberSoliant30-Sep-04 9:24 
Has anyone tested the UseTab = 0x00000008,

Use the tab to move thru the autocomplete possibilities instead of to the next dialog/window control.

I can't get the desired effect ?


Denn Gott hat die Menschen so sehr geliebt, daß er seinen einzigen Sohn für sie hergab. Jeder, der an ihn glaubt, wird nicht verlorengehen, sondern das ewige Leben haben

GeneralCustomised popup Pin
malik1012-Jul-04 0:13
membermalik1012-Jul-04 0:13 
GeneralSystem.Windows.Forms.Keys.Return Pin
Dr Jeeni4-Jan-04 6:11
memberDr Jeeni4-Jan-04 6:11 
GeneralGreat post! Pin
AniaD24-Oct-03 13:04
memberAniaD24-Oct-03 13:04 
GeneralExtend combo Box for normal dropdown Pin
Anonymous6-Nov-02 5:21
memberAnonymous6-Nov-02 5:21 
GeneralUnable to select text with the mouse Pin
22-Sep-02 16:57
member22-Sep-02 16:57 
GeneralRe: Unable to select text with the mouse Pin
James T. Johnson22-Sep-02 19:00
editorJames T. Johnson22-Sep-02 19:00 
GeneralUnmanaged code Pin
Ray Cassick18-Jul-02 11:38
memberRay Cassick18-Jul-02 11:38 
GeneralRe: Unmanaged code Pin
Heath Stewart9-Mar-03 20:06
editorHeath Stewart9-Mar-03 20:06 
QuestionWeb portion does not work on Win2k? Pin
Ray Cassick13-Jul-02 15:30
memberRay Cassick13-Jul-02 15:30 
AnswerRe: Web portion does not work on Win2k? Pin
Steve Miller20-Oct-03 11:46
memberSteve Miller20-Oct-03 11:46 
GeneralExend this ComboBox to Datasets Pin
Ben Kloosterman4-Apr-02 17:22
memberBen Kloosterman4-Apr-02 17:22 
GeneralCatching KeyEventHandler Pin
Jarrett Vance26-Feb-02 9:53
memberJarrett Vance26-Feb-02 9:53 
GeneralRe: Catching KeyEventHandler Pin
Carlos Antollini26-Feb-02 10:21
memberCarlos Antollini26-Feb-02 10:21 
GeneralRe: Catching KeyEventHandler Pin
George Jacob14-Feb-05 4:49
memberGeorge Jacob14-Feb-05 4:49 

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.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web06-2016 | 2.8.180920.1 | Last Updated 26 Feb 2002
Article Copyright 2002 by Rama Krishna Vavilala
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid