Formatting the ComboBox editing window

  • Thread starter Thread starter Tom McL.
  • Start date Start date
T

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
 
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
 
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
 
Hello Tom,

Try using Monospaced font, like the Courier.

Regards
Cyril
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top