Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CListBox or Grid?

Status
Not open for further replies.

fdsouth

Technical User
Jun 6, 2001
61
US
I am reading in text from a file and putting grouped data into 3 CStrings. For example, the file has text arranged as so...

Housing 226452 Text1 Text2 Text3
R Leaflet 923411 Text1 Text2 Text3
L Leaflet 821212 Text1 Text2 Text3
Housing 124452 Text1 Text2 Text3
R Leaflet 133411 Text1 Text2 Text3
L Leaflet 121272 Text1 Text2 Text3

I go through, line by line, and pull the appropriate data into 3 different CStrings...

CString Housing: CString RLeaflet: CString LLeaflet:
226452 923411 821212
124452 133411 121272

I would like to show the data in a listbox (CListbox) but have not been able to figure out how to show three columns of data. I doubt the CListBox class allows this (as far as I can tell) but I don't know what other choices are available. Any suggestions?
 
You should use CListCtrl or CListView instead of CListBox.
CListBox is only for one column.
 
There's another choice you have if you want to display multiple rows and columns of data. Microsoft VC++ 6.0 also includes a couple of "limited" function grids, such as FlexGrid. To add it to your project, follow these steps:

1) On the "Project" menu, select "Add to project"
2) select "Components and Controls"
3) select "Registered ActiveX Controls"
4) choose "Microsoft FlexGrid Control, version 6.0"

The control will now be at the end of your "Controls" palate. After adding the control, the "msflexgrid.h" file will be added to your project, which contains the member functions you can use. The following functions should go a long way towards what you need:

// set maximum size of grid
void SetRows(long nNewValue);
void SetCols(long nNewValue);

// set current grid coordinates
void SetRow(long nNewValue);
void SetCol(long nNewValue);

// set text in the current cell
void SetText(LPCTSTR lpszNewValue);

There are many more functions, but this should give you the idea of what is possible. If you eventually need more functionality, a commercial version of FlexGrid is available. Or you could check into FarPoint Spread.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top