Click here to Skip to main content
Licence 
First Posted 14 Aug 2007
Views 50,241
Downloads 2,303
Bookmarked 57 times

Expandable List Control to Accept Multilines

By | 14 Aug 2007 | Article
A derived CListCtrl class that expands its rows when it receives multilines

Sample Image

Introduction

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.

Cautions

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.

History

  • 9th August, 2007
    • Initial release.

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

About the Author

Carlos Souza

Software Developer

Brazil Brazil

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionNot able to select multiple items and delete PinmemberDinakara K3:49 3 Jan '12  
Questiondeleting multiple selected items .. PinmemberDinakara K19:07 1 Jan '12  
QuestionDeleting Selected Itemes PinmemberDinakara K22:39 29 Dec '11  
GeneralNo meet my intentions PinmemberITGrit4:55 13 Mar '11  
GeneralNice PinmemberITGrit5:05 11 Mar '11  
GeneralHelp for CheckBox Pinmembercute_friend707719:26 6 Dec '10  
Generalexpand all Pinmembernekitusan23:35 30 Aug '09  
AnswerRe: expand all PinmemberUrbanBlues0:48 8 Nov '09  
GeneralSmall problem with excellent control Pinmemberbillgatest9:09 30 Aug '08  
GeneralRe: Small problem with excellent control PinmemberCarlos Souza3:11 9 Sep '08  
GeneralRe: Small problem with excellent control Pinmemberbillgatest19:06 3 Oct '08  
GeneralVery handy for something I'm doing right now PinmemberPaul Roberts2:14 5 Jun '08  
GeneralThis just might solve an issue I've put off Pinmemberc-sharp7:31 16 Aug '07  
GeneralRe: This just might solve an issue I've put off PinmemberCarlos Souza11:03 16 Aug '07  
GeneralRe: This just might solve an issue I've put off Pinmemberdebehe16:44 31 Aug '07  
GeneralVery Interesting Pinmember.dan.g.13:34 14 Aug '07  
AnswerRe: Very Interesting PinmemberCarlos Souza1:08 15 Aug '07  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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 | Mobile
Web03 | 2.5.120517.1 | Last Updated 14 Aug 2007
Article Copyright 2007 by Carlos Souza
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid