?
Solved

CListBox multicolumn

Posted on 2004-11-22
1
Medium Priority
?
5,807 Views
Last Modified: 2013-11-20
Hi can some one please post an example how to create and use multicolumn listbox...

CListBox * listBox = new CListBox();
listBox->Create(LBS_MULTICOLUMN | LBS_HASSTRINGS | WS_VISIBLE | WS_BORDER, CRect(20, 20, 170, 170), this, 65536);
    listBox->SetColumnWidth(35);
    listBox->AddString("qq");

this is my example, but it has only one column.. how to add a new column and data into it?

thanx
0
Comment
Question by:GiedriusS
1 Comment
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 400 total points
ID: 12649225
You can't take full control about multiple columns in a listbox, it is virtually a single column that is wrapped, so you can't ensure to put many columns for a same row aligned. Better you can use a CListCtrl instead, in "report" mode. Look at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/_mfc_clistctrl.asp

There are some examples at codeproject.com, but a simple on could be:

CListCtrl *listCtrl = new CListCtrl();
listCtrl->Create(WS_VISIBLE|WS_BORDER|LVS_REPORT, CRect(20, 20, 170, 170), this, 65536);
listCtrl->InsertColumn(0, "1st", 35);
listCtrl->InsertColumn(1, "2nd", 35);
listCtrl->InsertColumn(2, "3rd", 35);

listCtrl->InsertItem(0, "");
listCtrl->SetItemText(0,1,"FIRST");
listCtrl->SetItemText(0,1,"SECOND");
listCtrl->SetItemText(0,1,"THIRD");

Some related articles:
http://www.codeproject.com/listctrl/listctrldemo.asp
http://www.codeproject.com/listctrl/clistctrl_insertrow.asp
http://www.codeproject.com/listctrl/creportctrl.asp
http://www.codeproject.com/listctrl/clistctrlrant.asp

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month15 days, 19 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question