Link to home
Start Free TrialLog in
Avatar of jsopher
jsopher

asked on

listbox with columns

hey all,

need to add 2 recordset items to the same listbox.

the character length varies among the strings, but i am trying to get them to line up.

for example:

Home 800.555.1234
Office 800.555.2697

SHOULD BE....

Home          800.555.1234
Office           800.555.2697
ASKER CERTIFIED SOLUTION
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Since you only are calling this once, you can abreviate the following line:
SendMessageArray List1.hWnd, LB_SETTABSTOPS, CLng(UBound(TabStops) - LBound(TabStops) + 1), TabStops(LBound(TabStops))

As follows:
SendMessageArray List1.hWnd, LB_SETTABSTOPS, 1, TabStops(0)

Anthony
The standard listbox does not support multiple columns, but if you set the font to Courier New (or other fixed-point font like Win2000's Lucida Console) it will be pretty easy to line things up.

Alternately, you can get a listbox that supports multiple columns, like the one that comes with Access and is part of the MS Forms 2.0 Object Library. (Note that this particular one can only be distributed with permission from MS, although you could try to write your own!)
rspahitz,

>> it will be pretty easy to line things up <<
This is basically what the code I posted does, without the need to use Fixed Fonts.

Anthony
If you already have reference to "Microsoft Windows Common Controls" component, use ListView control in Report view.
Good job, Anthony.

However, I always try to avoid API calls when not necessary, simply because they are likely to break in future versions, especially with .net looming...

In this case, they might be necessary...if you want a proportional font.
Avatar of VincentLawlor
VincentLawlor

Have to agree with ameba on this one use a ListView control instead of a List control. No messing around with API calls, Fonts, positioning columns etc.

Vin.
Avatar of jsopher

ASKER

thanks man,

worked like a charm - exactly what i wanted.
Jst, optionally, you could add microsoft forms component to toolbox and use listbox from it since it has columns property.
It uses resources and i don't know if it is redistributable.
Cheers