Click here to Skip to main content
Licence 
First Posted 2 Jan 2002
Views 138,825
Downloads 1,597
Bookmarked 43 times

A Class to Save and Load Listbox Data

By | 2 Jan 2002 | Article
CListBoxSafe is a class that can save data from a listbox to file and load data from a file into a listbox.

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

Member

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

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Generalhelp me Pinsussjazz22:01 21 Dec '07  
Generalsave and load listbox data Pinmemberanuj vohra21:13 9 May '06  
GeneralNice idea but severely flawed! Pinmemberarzer4:48 3 Mar '05  
GeneralRe: Nice idea but severely flawed! PinmemberKuniva12:00 3 Mar '05  
GeneralRe: Nice idea but severely flawed! Pinmemberwise.bear17:47 14 Apr '10  
GeneralWorking good, but... Pinmembermacrophobia15:36 15 Feb '05  
Generali cant downloadit Pinmembertitanflan11:39 4 Jan '03  
Generalerror PinsussAnonymous9:52 2 Sep '02  
QuestionHow can i use this class? PinsussAnonymous22:27 15 Aug '02  
GeneralExcellent! PinmemberSelevercin6:04 12 Jan '02  
GeneralIts good PinmemberThe Eclypse10:06 3 Jan '02  
GeneralRe: Its good PinmemberKuniva2:07 4 Jan '02  
GeneralRe: Its good PinmemberMNS0:18 14 Jan '03  
GeneralRe: Its good PinmemberSelevercin6:07 12 Jan '02  
GeneralRe: Its good PinmemberBret Faller13:21 2 Aug '02  
GeneralRe: Its good PinmemberNnamdi Onyeyiri23:04 2 Aug '02  
GeneralRe: Its good Pinmemberchen15:51 10 Sep '02  
GeneralRe: Its good Pinmemberjaysnanavati2:04 24 Jan '09  
AnswerRe: Its good PinmemberBret Faller9:24 24 Jan '09  

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