Click here to Skip to main content
13,198,075 members (60,440 online)
Click here to Skip to main content
Add your own
alternative version


67 bookmarked
Posted 14 Aug 2007

Expandable List Control to Accept Multilines

, 14 Aug 2007
Rate this:
Please Sign up or sign in to vote.
A derived CListCtrl class that expands its rows when it receives multilines

Sample Image


Because the CListCtrl class can't show different row heights, I created this derived class to simulate big strings in multilines. After inserting a multiline string into a list cell, the CListCtrl class shows strange symbols to represent endlines ('\r\n'). This project draws a tiny key symbol [+] before a big string, allowing the user to expand or contract the row with a double-click.

How this Class Works

This project is ready to replace CListCtrl when you need to present a multiline string. It draws its own gridlines, so you shouldn't use the LVS_EX_GRIDLINES extended style. Use the ShowGrid(bool) function to show/hide gridlines and the ShowMinimized(bool) function to show/hide the whole string in the row when minimized. The code redraws all list items, drawing key symbols [+] before a big string. When it finds a big string, the class saves the number of lines with SetItemData. After the user clicks twice over the row, the class inserts more rows below to represent the whole string. It then redraws the list to simulate a unique row. Clicking again, the class deletes extra lines, minimizing the row.

Using the Code

  1. Insert the MultiLineListCtrl.h and MultiLineListCtrl.cpp files into your project.
  2. Create a list control.
    • Set the view property of your list to report.
  3. Create a CListCtrl member variable in your class.
  4. Insert the following code:
    #insert "MultiLineListCtrl.h"
  5. Replace your CListCtrl member variable with a CMultiLineListCtrl member variable.


This project is as simple as possible. It changes the number of rows and uses the item data. Close all rows, i.e. use CloseAll(), before working with its cells or overwriting its basic functions.


  • 9th August, 2007
    • Initial release.


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

Carlos Souza
Software Developer
Brazil Brazil
No Biography provided

You may also be interested in...


Comments and Discussions

QuestionNot able to select multiple items and delete Pin
Dinakara K3-Jan-12 3:49
memberDinakara K3-Jan-12 3:49 
Questiondeleting multiple selected items .. Pin
Dinakara K1-Jan-12 19:07
memberDinakara K1-Jan-12 19:07 
QuestionDeleting Selected Itemes Pin
Dinakara K29-Dec-11 22:39
memberDinakara K29-Dec-11 22:39 
GeneralNo meet my intentions Pin
ITGrit13-Mar-11 4:55
memberITGrit13-Mar-11 4:55 
GeneralNice Pin
ITGrit11-Mar-11 5:05
memberITGrit11-Mar-11 5:05 
GeneralHelp for CheckBox Pin
cute_friend70776-Dec-10 19:26
membercute_friend70776-Dec-10 19:26 
Generalexpand all Pin
nekitusan30-Aug-09 23:35
membernekitusan30-Aug-09 23:35 
AnswerRe: expand all Pin
UrbanBlues8-Nov-09 0:48
memberUrbanBlues8-Nov-09 0:48 
GeneralSmall problem with excellent control Pin
billgatest30-Aug-08 9:09
memberbillgatest30-Aug-08 9:09 
GeneralRe: Small problem with excellent control Pin
Carlos Souza9-Sep-08 3:11
memberCarlos Souza9-Sep-08 3:11 
GeneralRe: Small problem with excellent control Pin
billgatest3-Oct-08 19:06
memberbillgatest3-Oct-08 19:06 
GeneralVery handy for something I'm doing right now Pin
Paul Roberts5-Jun-08 2:14
memberPaul Roberts5-Jun-08 2:14 
GeneralThis just might solve an issue I've put off Pin
c-sharp16-Aug-07 7:31
memberc-sharp16-Aug-07 7:31 
GeneralRe: This just might solve an issue I've put off Pin
Carlos Souza16-Aug-07 11:03
memberCarlos Souza16-Aug-07 11:03 
GeneralRe: This just might solve an issue I've put off Pin
debehe31-Aug-07 16:44
memberdebehe31-Aug-07 16:44 
GeneralVery Interesting Pin
.dan.g.14-Aug-07 13:34
member.dan.g.14-Aug-07 13:34 
AnswerRe: Very Interesting Pin
Carlos Souza15-Aug-07 1:08
memberCarlos Souza15-Aug-07 1:08 

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.171020.1 | Last Updated 14 Aug 2007
Article Copyright 2007 by Carlos Souza
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid