Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C++
test=CreateWindow("listbox", NULL, WS_VISIBLE|WS_CHILD|WS_BORDER|LBS_NOTIFY|LBS_MULTICOLUMN, 120,70,250,330, hwnd, (HMENU)IDM_BLB, NULL, NULL);


After creating above listbox, I want to put string in listbox using LB_ADDSTRING
But the problem is that I don't know how to distinguish two columns
C++
SendMessage(test, LB_ADDSTRING, 0, (LPARAM)"where");

If I do like above code, the string will be displayed in first column.
How can I display data in the column that I want to put in ?

[Edit]Code block added[/Edit]
Posted
Updated 28-Nov-12 5:41am
v2
Comments
CPallini 28-Nov-12 13:46pm    
A List Box with such style automatically arranges items on multiple columns, as Richard suggested, use a ListView instead.

You don't; a List Box[^] is a simple list of items. If you want a list with multiple columns then you must use a List View[^].

I just realised that I explained this to you yesterday in this question[^]. Please read the documentation that I have provided the links for rather than repeat the same question again.
 
Share this answer
 
v2
Comments
CPallini 28-Nov-12 13:44pm    
5.
This answer is a bit late but here goes

LBS_MULTICOLUMN is meant for horizontal scrolling. All the columns are the same size and the size has to be set by using LB_SETCOLUMNWIDTH. If for example, there is a lisbox of 4 rows and 3 columns, [row 1, column 2] is the 5th string, [row 2, column 3] is the 9th string.

LBS_MULTICOLUMN does not respond to a WM_VSCROLL and cannot be used with LBS_OWNERDRAWVARIABLE. Basically, you can't easily do all the things you would like to do with a listbox.

It is a lot easier to use a listview for multiple columns except that, unlike listboxes, it cannot handle variable height rows.
 
Share this answer
 
Comments
Richard MacCutchan 26-Mar-15 10:06am    
Please don't post answers to questions more than two years old.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900