Click here to Skip to main content
13,352,280 members (72,902 online)
Click here to Skip to main content
Add your own
alternative version


49 bookmarked
Posted 5 Jul 2003

ControlExtender Library

, 5 Jul 2003
Rate this:
Please Sign up or sign in to vote.
A component that enhances standard ListView and ListBox controls. (full designer support)

Sample Image - extendertest.png


The control extender library contains three components:

  • ListViewExSort
    provides a ListView control with sorting capabilities.
  • ListViewExEdit
    provides a ListView control with editing capabilities.
  • ListBoxExEdit
    provides a ListBox control with editing capabilities.

To note here is that ListViewExSort shows the sort up/down arrows only under XP, because it uses functionality from comctrl version 6.0 which is only distributed with XP.


From two projects I had two different classes which inherited from listview to extend its functionality. I felt that merging the two classes into one was not the right approach. Fortunately, I found the article ListViewSortManager control by Eddie Velasquez which gave me the idea not to inherit but to 'extend' listviews functionality.

Using the code

To use the extender controls, they have to be added to the toolbox first. The extenders can then be dropped onto a form where they will show up in the component tray. They can then be configured by setting the appropriate properties.

The image below shows the properties for ListViewExSort.

ListView Properties

The most important property is the control that the extender is associated with. This can also be coded manually like:


The only property that can't be set with the designer is comparer. By default (if no comparers are provided) the columns will be sorted as a case-sensitive string. If sorting should be performed by something else, a custom sorter must be provided. The following code shows how to code a number comparer:

class Int32Comparer : IListViewComparer
    public int OnCompare(string x, string y)
            return int.Parse(x, NumberStyles.Number) - 
                                int.Parse(y, NumberStyles.Number);
        catch (System.Exception)
            return -1;

The comparer class must be attached to the listview extender as follows:

listViewExSort1.Comparer=new IListViewComparer[]
      new Int32Comparer(),

The sample above will sort the second column by number and all other columns by text.

Points of Interest

Key Navigation

What's not so obvious, is that ListBoxExEdit supports key-naviagtion. It is switched off by default. The following code enables it:

this.listBoxExEdit1.KeyNavigation = true;

Also note that the followging key-mappings are hardcoded into the library:

Ctrl-Insert- Insert a new line above the currently selected line
Ctrl-Delete- Delete the selected line
Ctrl-Down- Move the selected line down
Ctrl-Up- Move the selected line up


The sample project is for VS.NET 2003. Fortunately, there is a project available that converts 2003 files back to VS.NET.
A converted project will fail to compile on

Application.EnableVisualStyles(); // .NET 1.1 only

because EnableVisualStyles is only available in .NET 1.1. This line can be removed but the xp-look will then not be available.

Final Note

The control extender library is not yet ready to be used in all kinds of projects. Parts of it are hardly tested and I expect it to fail in ways I've never tested it before. For me, these three controls are useful and I intend to improve functionality and reliability as I work with them. I hope that there are some people out there that can live with the limited functionality and can give me feedback on how to improve.


  • Initial Release: July 6, 2003


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


About the Author

Reto Ravasio
Switzerland Switzerland
No Biography provided

You may also be interested in...


Comments and Discussions

QuestionExtending a listbox with a progressBar Control Pin
eRRaTuM17-May-06 6:41
membereRRaTuM17-May-06 6:41 
Generalerror Pin
juli80243-May-05 23:15
memberjuli80243-May-05 23:15 
I am editing a sub item in the listview (using the dll presented here) and while doing it I get this error:
An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in

Additional information: Specified argument was out of the range of valid values.

And the debuger falls on those lines:

this.textBox.Text = this.listView.Items[indices.ItemIndex].SubItems[indices.SubItemIndex].Text;

Could you please explain me why?
Thank you very much!

QuestionHow to use the LIstViewExEdit Pin
Anonymous14-Apr-05 0:01
sussAnonymous14-Apr-05 0:01 
AnswerRe: How to use the LIstViewExEdit Pin
Reto Ravasio15-Apr-05 9:50
memberReto Ravasio15-Apr-05 9:50 
GeneralRe: How to use the LIstViewExEdit Pin
juli802416-Apr-05 5:11
memberjuli802416-Apr-05 5:11 
GeneralRe: How to use the LIstViewExEdit Pin
Reto Ravasio17-Apr-05 5:33
memberReto Ravasio17-Apr-05 5:33 
GeneralRe: How to use the LIstViewExEdit Pin
juli802418-Apr-05 22:48
memberjuli802418-Apr-05 22:48 
GeneralAscending Descending Arrow Pin
shakhshir3-Apr-05 6:51
membershakhshir3-Apr-05 6:51 
GeneralRe: Ascending Descending Arrow Pin
Reto Ravasio3-Apr-05 13:00
memberReto Ravasio3-Apr-05 13:00 
GeneralProgress Bar in ListView Pin
Bluetears21-Sep-03 5:17
memberBluetears21-Sep-03 5:17 
GeneralHideSelection Bug Pin
Yoeri12-Jul-03 23:42
memberYoeri12-Jul-03 23:42 
GeneralRe: HideSelection Bug Pin
Reto Ravasio14-Jul-03 9:25
memberReto Ravasio14-Jul-03 9:25 

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 | Terms of Use | Mobile
Web04 | 2.8.180111.1 | Last Updated 6 Jul 2003
Article Copyright 2003 by Reto Ravasio
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid