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
LVL 8
Vinayak KumbarSr Program ManagerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

inprasCommented:
Why don't U try using multiple column list box?
0
Vinayak KumbarSr Program ManagerAuthor Commented:
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

0
SteveGTRCommented:
Select the "Use tabstops" option (LBS_USETABSTOPS) on the dialog editor for your list box. The following code sets the tab stops:

int nTabs[] = { 100 };

m_ListBox.SetTabStops(1, nTabs);
m_ListBox.AddString("abcd\t100");
m_ListBox.AddString("cdedefg\t200");

Good Luck,
Steve




0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

Vinayak KumbarSr Program ManagerAuthor Commented:
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
0
SteveGTRCommented:
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
0
Vinayak KumbarSr Program ManagerAuthor Commented:
Hi,

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

VinExpert
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.