Click here to Skip to main content
Click here to Skip to main content

A Class to Save and Load Listbox Data

By , 2 Jan 2002
 
<!-- Download Links --> <!-- Add the rest of your HTML here -->

Introduction

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);

and

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.

Example

CListBoxSafe::SaveList(m_lMyList,"test.dat",0,0);
CListBoxSafe::LoadList(m_lDataList,"data.txt",0,0);

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

Kuniva

Belgium Belgium
bla bla bla

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

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
Generalhelp mesussjazz21-Dec-07 22:01 
Generalsave and load listbox datamemberanuj vohra9-May-06 21:13 
Plz send me this whole project to save and load data as i m in need of that .
Plz send me on my id
anuj_vohra83@yahoo.co.in
 
anuj vohra
GeneralNice idea but severely flawed!memberarzer3-Mar-05 4:48 
GeneralRe: Nice idea but severely flawed!memberKuniva3-Mar-05 12:00 
GeneralRe: Nice idea but severely flawed!memberwise.bear14-Apr-10 17:47 
GeneralWorking good, but...membermacrophobia15-Feb-05 15:36 
Generali cant downloaditmembertitanflan4-Jan-03 11:39 
GeneralerrorsussAnonymous2-Sep-02 9:52 
QuestionHow can i use this class?sussAnonymous15-Aug-02 22:27 
GeneralExcellent!memberSelevercin12-Jan-02 6:04 
GeneralIts goodmemberThe Eclypse3-Jan-02 10:06 
GeneralRe: Its goodmemberKuniva4-Jan-02 2:07 
GeneralRe: Its goodmemberMNS14-Jan-03 0:18 
GeneralRe: Its goodmemberSelevercin12-Jan-02 6:07 
GeneralRe: Its goodmemberBret Faller2-Aug-02 13:21 
GeneralRe: Its goodmemberNnamdi Onyeyiri2-Aug-02 23:04 
GeneralRe: Its goodmemberchen10-Sep-02 15:51 
GeneralRe: Its goodmemberjaysnanavati24-Jan-09 2:04 
AnswerRe: Its goodmemberBret Faller24-Jan-09 9:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130617.1 | Last Updated 3 Jan 2002
Article Copyright 2002 by Kuniva
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid