Home All Groups Group Topic Archive Search About

Formatting the ComboBox editing window

Author
15 Jan 2006 4:34 PM
Tom McL.
I have a ComboBox1 one that is populated by an

arrayList. Once I select an item I would like the selected

item to be displayed in the editing window with the string

divided in half with the first half to be displayed on the far

left and the other half displayed to the far right. I have tried

string formatting with little success. I using VB2005

standard version.



Thanks



tm

Author
15 Jan 2006 4:47 PM
Cyril Gupta
Hello Tom,

Your description makes me feel that you want the functionality of a
multi-column combo box. Hmmm... It can probably be done using some string
manipulation, but you will get inexact returns unless you use a mono-spaced
font.

If you use a regular font then the width of each character in the string
will be different and the string which is supposed to be right aligned won't
come in right.

If you are interested in the text based solution, this is what the logic is.

Find the number of characters that can fit in one line of the combo. Count
the number of chars in the string you have. Subtract the number from the
number of characters in the combo. Put the first half of the string in a
string, then add the number of the spaces that are left after subtracting.
Now add the rest half of the string... Hmm... Did I explain things properly
over there?

The second idea is better... Modify the combo box and write your own paint
code.

You might want to start with a multi column combo. There are several on the
net.

Regards
Cyril gupta
Author
15 Jan 2006 11:05 PM
Tom McL.
Cyril,



I have tried your first suggestion but was not satisfied with the look.

It was so easy in VB5 using Twips so I tried to figure out if Pixel

could do the job, but know luck.

Thanks, for the suggestions.



tm
Author
16 Jan 2006 12:11 AM
Cyril Gupta
Hello Tom,

Try using Monospaced font, like the Courier.

Regards
Cyril