Click here to Skip to main content
12,898,174 members (57,590 online)
Click here to Skip to main content
Add your own
alternative version


19 bookmarked
Posted 21 Aug 2002

List Control in the guise of a grid

, 21 Aug 2002
Rate this:
Please Sign up or sign in to vote.
This article shows how to make the listcontrol to act as a grid control.
<!-- Article image -->


This article presents an ActiveX Listview control developed using ATL/WTL which acts as a grid control with the facility to edit subitems, add/modify/delete rows. This is an owner drawn control, and displays the editable rows and read-only rows in different color. This control can be used in VB, IE, etc.


The activex listview control implemented using WTL classes has the support for editing subitems and basic user navigation. To edit an editable subitem, double click on the item and after modification hit the enter key and you are done. The control also provides the interface to insert columns and rows from clients like VB or IE.

The rows can be added by calling the interface methods or by using the mouse. To add the row just right click on the control and select "add row". Here I have given provision to add two types of rows, editable and read only. The editable rows are red in color and the read only rows are in blue color. Before inserting the rows into the list control, the number of columns has to be specified as shown in the client program. Sample client is writted in VB as well as in HTML. Properties to set height, width and the position on the screen are supported.


This control is based on the Edit and SysListview32 controls in Windows. The control is an owner drawn control. To edit the subitems in the list control, I just display the edit control at that place and set its text to the text in that subitem and after hitting the Enter key I set that particular item of the list control with the new text. I have modified the SetObjectRects function to support the positioning and the height/width properties of the control. The itemdata is stored in the CArray class, since I was unable to store the data in the lparam of the LVITEM structure. If anybody can get rid of the array please put a mail to me ;-)

The activex control was built with Visual C++ 6.0 Enterprise Edition on Windows 2000 Professional edition. I have commented the code wherever I felt necessary. Thanks to Todd C. Wilson for providing the header file to optimize the code. it certainly helped in reducing the code. Read to reduce the code size.

Drop me a line when you find any bugs or if you have any comments / suggestions / improvement at all to this ActiveX listview control. Furthur improvements that can be done to this control is to make the columns datatype specific and also display combo box where ever appropriate to modify the data in the cell.


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

Sharan Basappa
Team Leader
India India
He is a graduate, currently working as a Software Engineer in Bangalore, India. You can reach him at

You may also be interested in...


Comments and Discussions

QuestionCan the position of control be changed ? Pin
mnsam19-Aug-10 3:57
membermnsam19-Aug-10 3:57 
AnswerRe: Can the position of control be changed ? Pin
Sharan Basappa19-Aug-10 4:19
memberSharan Basappa19-Aug-10 4:19 
GeneralRe: Can the position of control be changed ? Pin
mnsam19-Aug-10 20:00
membermnsam19-Aug-10 20:00 
GeneralRe: Can the position of control be changed ? Pin
Sharan Basappa20-Aug-10 1:10
memberSharan Basappa20-Aug-10 1:10 
Questionhow the cycle throught the edit controls by using VK_TAB when the activeX is hosted in a HTML-document? Pin
stefanb2-Feb-05 2:46
memberstefanb2-Feb-05 2:46 
AnswerRe: i think i managed to get through... Pin
stefanb3-Feb-05 4:24
memberstefanb3-Feb-05 4:24 
QuestionChanging color of grid? Pin
Stratofortress5-Aug-03 23:24
memberStratofortress5-Aug-03 23:24 
AnswerRe: Changing color of grid? Pin
Sharan2-Nov-03 22:39
memberSharan2-Nov-03 22:39 

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
Web02 | 2.8.170424.1 | Last Updated 22 Aug 2002
Article Copyright 2002 by Sharan Basappa
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid