Click here to Skip to main content
13,050,358 members (138,778 online)
Rate this:
Please Sign up or sign in to vote.
See more:

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
Updated 28-Nov-12 5:41am
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.
Rate this: bad
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.
CPallini 28-Nov-12 13:44pm
Rate this: bad
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.
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 26 Mar 2015
Copyright © CodeProject, 1999-2017
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