Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Right Aligning Text in Combo Box 1

Status
Not open for further replies.

webmonkey323

Programmer
Dec 17, 2002
10
GB
Hi,

I'm pretty sure the answer to this is no, but is there ANY way at all to right align text in a VB combo box????

I have a combo box with the style set to 2 - Dropdown List. I have checked lots of API functions and messages to try and alter the text alignment but have so far drawn blanks. Are there any API routines out there which could help me achieve this???

Any help you can provide would be greatly appreciated.

Thanks.
 
Thanks for that - I'd come across this previously but I think its only applicable for .NET controls. I'm currently using VB6 on NT4 and unfortunately these API calls don't alter the layout / alignment.

Thanks anyway.
 
It works with vb6 just copy the code into a form module add 3 check boxes and a combo. If you check just the first check box you get the results you're looking for.
 
Hmm...I've tried that and it hasn't made any difference. Tha API call to bring the drop down works fine, but the text is still left aligned. Do you think it might be an operating system oddity? Are you using W2K / XP? I'm currently on NT4. Thanks again for the help.
 
I am using XP, so I tested an NT4 machine and it didn't work. hmmmmm.
 
I found a solution for you. see thread thread222-525710 just modify this line

S = Space$((ClientWidth - TextWidth(S)) / SpaceWidth / 2) & S
to
S = Space$((ClientWidth - TextWidth(S)) / SpaceWidth - 8) & S

Remember to thank Hypetia.
 
Excellent, that's just the job!! I was just about to give up on this...I'm amazed its proved so hard to do!!! There's a star on its way to you.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top