Results 1 to 12 of 12

Thread: Combo Box

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Posts
    208

    Question Combo Box

    I have a problem regarding combo box
    When i add 2 columns in a combo box how can I align them properly

    i have used combo.additem rs(0) & " " & rs(1)

    the output is as :

    abcdefgh This is my first rec.
    abcd this is my second record
    ab this is my third record

    So you see the 2nd column is not aligned in a straight line.
    I have even tried adding spaces , calculating length og rs(0) and adding spaces accordinglr but to no avail.

    Please advise

    thnks

  2. #2
    PowerPoster
    Join Date
    Aug 2002
    Location
    NY, NY
    Posts
    2,139
    Try using this instead:

    combo.additem rs(0) & vbTab & rs(1)

    Roy

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Posts
    208

    Red face combo box

    The vbtab does not work
    because
    the font size of space is less than the font sizze of say letter"Z"
    hence even if i add 5 spaces = 1 tab then also it does nort work

    Pls advise

  4. #4
    PowerPoster
    Join Date
    Aug 2002
    Location
    NY, NY
    Posts
    2,139
    Not true. get TextWidth or Len of a longest value for a Field1 and add vbTab to it. As simple as that.

  5. #5
    PowerPoster
    Join Date
    Aug 2002
    Location
    NY, NY
    Posts
    2,139
    Also, you better use True type font for your combo (Arial, Courier, MS Sans Serif, etc)

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Posts
    208

    Combo Box

    I have tried using
    combo.additem rs(0) & vbtab & rs(1)

    My output in the drop down combo box is as

    abcdefg|this is my first record
    abc|this is my second record
    abcdefghij|this is my third record

    My rs(0) is varchar2(12) i.e. it can accept upto 12 characters.
    my rs(1) is varchar2(20) ..... 20 characters

    I am using Ms Sans Serif font ... font size = 8

    As you can see if the user enters say only 3 characters in rs(0)
    ALWAYS then I dont have a problem but when his entry of characters is random the 2nd column does not align itself properly.

    Please advise as I am a student doing a project and have
    used the combo box in most of my modules

    P.s. Is there any chance that without changing my code I can use
    imagecombo box for these alignment of columns

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Posts
    208
    Now help me in the above query Please
    I am doing aproject and am stuck in this mess

  8. #8
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Newbury, UK
    Posts
    1,878
    EITHER use two combo boxes very close to each other.

    Or look at using the ListView object, in report format.

    Look in this forum for many examples.

  9. #9
    Fanatic Member
    Join Date
    Apr 2002
    Posts
    638
    alternatively, use the Microsoft Forms 2.0 Object Library. that has a combobox in that supports multiple columns.

  10. #10
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    Try adding spaces to fill the maximum length:

    combo.additem rs(0) & string(12-len(rs(0)),32) & vbtab & rs(1)

    string(x,y) returns X characters of code Y (32 is space)

  11. #11
    PowerPoster
    Join Date
    Aug 2002
    Location
    NY, NY
    Posts
    2,139
    Try this but KIM that your loop may look different:
    VB Code:
    1. Dim i%, strText$, strF1$, strF2$
    2.  
    3.     For i = 0 To 9
    4.         strF1 = "Item" & i & "_Col1"
    5.         strF2 = "Item" & i & "_Col2"
    6.         strText = strF1 & Space(12 - Len(strF1) + 4) & strF2    'we add 3 extra spaces in case len(strF1)=12
    7.         Combo1.AddItem strText
    8.     Next i
    9.  
    10. End Sub

    Roy

  12. #12
    PowerPoster
    Join Date
    Aug 2002
    Location
    NY, NY
    Posts
    2,139
    Use of Microsoft Forms 2.0 Object Library REQUIRES ADDITIONAL LICENSING. You CANNOT distribute this controls freelly.

    Roy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width