Click here to Skip to main content
11,573,408 members (57,603 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ API
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
 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 28-Nov-12 5:39am
kyleK89363
Edited 28-Nov-12 5:41am
ProgramFOX159.5K
v2
Comments
CPallini at 28-Nov-12 13:46pm
   
A List Box with such style automatically arranges items on multiple columns, as Richard suggested, use a ListView instead.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
v2
Comments
CPallini at 28-Nov-12 13:44pm
   
5.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  
Comments
Richard MacCutchan at 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)

  Print Answers RSS


Advertise | Privacy | Mobile
Web04 | 2.8.150624.2 | Last Updated 26 Mar 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100