Formatting the ComboBox editing window

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tom McL.

    #1

    Formatting the ComboBox editing window

    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


  • Cyril Gupta

    #2
    Re: Formatting the ComboBox editing window

    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


    Comment

    • Tom McL.

      #3
      Re: Formatting the ComboBox editing window

      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


      Comment

      • Cyril Gupta

        #4
        Re: Formatting the ComboBox editing window

        Hello Tom,

        Try using Monospaced font, like the Courier.

        Regards
        Cyril


        Comment

        Working...