Link to home
Start Free TrialLog in
Avatar of Vinayak Kumbar
Vinayak Kumbar

asked on

URGENT: Space And List Box Relation

Hi,

I have list box variable m_ListBox. I want to display the strings something like
abcd       100
cdedefg  200

How I should insert the strings?. If I assign this string to a CString and insert them, they are not properly aligned. They are coming something like
abcd    100
cdedefg  200

I want the clear vision of columns.
I think I am clear to U.

Thanks,
VinExpert
Avatar of inpras
inpras

Why don't U try using multiple column list box?
Avatar of Vinayak Kumbar

ASKER

Hi inpras,
Thanks for ur response. But As U know it does not solve the problem. If it is multi col, I can't insert the items horizontally, but they go vertically and then come to next column, Which I don't want.

I am trying this, using single column and for user it should be displayed as multi column which is controlled by spaces.

VinExpert

ASKER CERTIFIED SOLUTION
Avatar of SteveGTR
SteveGTR
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
Hi,

I am doing the same. But for some it will not wirk properly. Again strings become disordered. Have U faced any such problems?. Just try by using variable length strings for those strings. U will get the problem. How to avoid that?

I am feeling list box is doing something with the extra spaces/tabs.

VinExpert
The only thing I can think is that your tab isn't large enough for some of your strings. To test it out set your tab at some number like 500 that you know will be large enough for all your strings. Do the columns line up?

I guess you could dynamically measure your strings to find out what the optimum tab should be:

// Set your string before the tab in str
CClientDC DC(this);
CFont* pOldFont = DC.SelectObject (GetFont());
CSize size = DC.GetTextExtent(str);
DC.SelectObject(pOldFont);

// Make tab equal to max size.cx + 10 or something

Hope this helps.

Steve
Hi,

I solved the prob, using some fonts. Thanks for directing me in that way.

VinExpert