Click here to Skip to main content
13,342,925 members (52,305 online)
Click here to Skip to main content
Add your own
alternative version


43 bookmarked
Posted 2 Jan 2002

A Class to Save and Load Listbox Data

, 2 Jan 2002
Rate this:
Please Sign up or sign in to vote.
CListBoxSafe is a class that can save data from a listbox to file and load data from a file into a listbox.
<!-- Download Links --> <!-- Add the rest of your HTML here -->


This is my first attempt at writing a class and at writing a Code Project article so I hope it will be of some use. I noticed I was using a lot of listbox saving/restoring in my applications so I decided to write a class for this. The class does not contain error handling but it should work fine. To use it just add the files to your project and include ListBoxSafe.h. There are (only) two functions you can use (simplicity):

void LoadList(CListBox &list, CString FileName, int MaxItems, int ItemLen);


void SaveList(CListBox &ListToFill, CString FileName, int MaxItems, int MaxItemLen);

list/ListToFill is the ListBox that you need to save or fill.
FileName is the name of the file from which you want to load or to which you want to save to.
MaxItems is the maximum amount of items to be saved or loaded.
ItemLen/MaxItemLen is the maximum length of a listbox item (should be the same if you save and load).

You can give MaxItems the value 0, and it will be 999 by default.
You can give MaxItemLen/ItemLen the value 0, and it will be 30 by default.




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

Belgium Belgium
bla bla bla

You may also be interested in...


Comments and Discussions

Generalhelp me Pin
jazz21-Dec-07 23:01
sussjazz21-Dec-07 23:01 
Generalsave and load listbox data Pin
anuj vohra9-May-06 22:13
memberanuj vohra9-May-06 22:13 
GeneralNice idea but severely flawed! Pin
arzer3-Mar-05 5:48
memberarzer3-Mar-05 5:48 
GeneralRe: Nice idea but severely flawed! Pin
Kuniva3-Mar-05 13:00
memberKuniva3-Mar-05 13:00 
GeneralRe: Nice idea but severely flawed! Pin
wise.bear14-Apr-10 18:47
memberwise.bear14-Apr-10 18:47 
GeneralWorking good, but... Pin
macrophobia15-Feb-05 16:36
membermacrophobia15-Feb-05 16:36 
Generali cant downloadit Pin
titanflan4-Jan-03 12:39
membertitanflan4-Jan-03 12:39 
Generalerror Pin
Anonymous2-Sep-02 10:52
sussAnonymous2-Sep-02 10:52 
QuestionHow can i use this class? Pin
Anonymous15-Aug-02 23:27
sussAnonymous15-Aug-02 23:27 
GeneralExcellent! Pin
Selevercin12-Jan-02 7:04
memberSelevercin12-Jan-02 7:04 
GeneralIts good Pin
The Eclypse3-Jan-02 11:06
memberThe Eclypse3-Jan-02 11:06 
GeneralRe: Its good Pin
Kuniva4-Jan-02 3:07
memberKuniva4-Jan-02 3:07 
GeneralRe: Its good Pin
MNS14-Jan-03 1:18
memberMNS14-Jan-03 1:18 
GeneralRe: Its good Pin
Selevercin12-Jan-02 7:07
memberSelevercin12-Jan-02 7:07 
GeneralRe: Its good Pin
Bret Faller2-Aug-02 14:21
memberBret Faller2-Aug-02 14:21 
GeneralRe: Its good Pin
Nnamdi Onyeyiri3-Aug-02 0:04
memberNnamdi Onyeyiri3-Aug-02 0:04 
GeneralRe: Its good Pin
chen10-Sep-02 16:51
memberchen10-Sep-02 16:51 
GeneralRe: Its good Pin
jaysnanavati24-Jan-09 3:04
memberjaysnanavati24-Jan-09 3:04 
AnswerRe: Its good Pin
Bret Faller24-Jan-09 10:24
memberBret Faller24-Jan-09 10:24 

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
Web01 | 2.8.180111.1 | Last Updated 3 Jan 2002
Article Copyright 2002 by Kuniva
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid