Results 1 to 11 of 11
  1. #1
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Combobox property for selecting entire text (WinXP/O2003)

    Hi,

    Trust this is a very simple Q, but cannot find the bl.... setting.

    What property do I have to set to get the entire text selected ("blued") when I launch a combobox on a form.

    Say that I've set .listindex=0 and would like an alphabetic progressive search in my combo based on each character the user provides...
    (ex. initial launch gives first company starting with an A.... user types "S" gives all company with S, types SA gives all companies with SA....etc.etc.)
    Bests,
    RD


    PS: Wish there were a knob on the TV to turn up the intelligence. There's a knob called "brightness," but that doesn't work

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Combobox property for selecting entire text (WinXP/O2003)

    I'm not sure I understand correctly, but have you experimented with the setting of the MatchEntry property of the combo box?

  3. #3
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combobox property for selecting entire text (WinXP/O2003)

    Hi Henrik

    Is this two separate questions?
    How to launch the combo with the .listindex=0 entry selected (blued) AND
    how to implement an "alphabetic progressive search"?

    These are two separate issues, if this is what you're asking.

    Alan

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Combobox property for selecting entire text (W

    Do you believe in kludges? Hopefully there is a better way:
    <pre>Private Sub UserForm_Initialize()
    With Me.ComboBox1
    .AddItem "First"
    .AddItem "Second"
    .AddItem "Third"
    .ListIndex = 0
    .SelStart = 0
    .SelLength = Len(.Value)
    End With
    End Sub
    </pre>

    On the second question, I think it has been covered.

  5. #5
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combobox property for selecting entire text (WinXP/O2003)

    JScher - I hoped it was that easy too. (see my various code attempts below - none of them seems to do the trick)
    Allan - no not really 2Q's, it's a single question. I was just trying to be extra thorough in my explanation... - didn't really seem to work, did it?? / ;o)
    Hans V, I've already tried with the .Matchentry and set it to "matchentrycomplete"

    All I need is that "item1" in my combobox is fully selected ("blued"), when I use the frmX.show method. (this will allow the user to get correct "type ahead" functionality instantly when the form launches. (see code below)

    I've already tried to achieve this with various combinations of .autowordselect, .seltext, .sellength, matchentry, enterfieldbehaviour.......etc. etc.

    I trust this is really simple and just a matter of a single setting. (... and obviously me explaining my intentions correctly/ ;o) )

    Private Sub UserForm_Initialize()
    Me.Caption = HR & " - Select company"
    FillCombo '(this fills combo with values from the database)
    With cmbCompany
    .ListIndex = 0
    .AutoWordSelect = True
    .EnterFieldBehavior = fmEnterFieldBehaviorSelectAll
    .MatchEntry = fmMatchEntryComplete
    .SelStart = 0
    .SelText = Len(.Value)
    ' .SelLength = Len(.Text)
    .SetFocus
    End With
    cmdOK.Default = True

    End Sub
    Bests,
    RD


    PS: Wish there were a knob on the TV to turn up the intelligence. There's a knob called "brightness," but that doesn't work

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Combobox property for selecting entire text (WinXP/O2003)

    The instructions

    With cmbCompany
    ...
    .ListIndex = 0
    .SelStart = 0
    .SelLength = Len(.Text)
    ...
    End With

    work for me - when the form is displayed, the first item from the list is selected in the text box part of the combo box. Apparently, it doesn't for you - what is wrong?

  7. #7
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combobox property for selecting entire text (WinXP/O2003)

    Hi Hans,

    I think the distinction lies in what we define as "selected".

    When I try this the line is also set correctly and the cursor is placed in front of the Word (.Selstart=0)
    What I am hoping to achieve is that the entire first "item" is fully selected - by that I mean that its marked in blue as well. It's this last bit I can't get to work.

    Are we still talking about the same here?

    Thx.
    Bests,
    RD


    PS: Wish there were a knob on the TV to turn up the intelligence. There's a knob called "brightness," but that doesn't work

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Combobox property for selecting entire text (WinXP/O2003)

    The entire text is selected (highlighted) when I do this, because of the line .SelLength = Len(.Text)

  9. #9
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Combobox property for selecting entire text (W

    I think you commented out the critical line during your testing. With the original code, no matter how I change the tab order or where I place the .SetFocus command, I cannot make it fail to highlight the desired value. So please try .SelLength again.

  10. #10
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combobox property for selecting entire text (WinXP/O2003)

    Hans & Jscher - you were both right, now it's working just fine.

    Thanks for your efforts.
    Bests,
    RD


    PS: Wish there were a knob on the TV to turn up the intelligence. There's a knob called "brightness," but that doesn't work

  11. #11
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combobox property for selecting entire text (W

    Hi Jefferson

    It's my experience that the "kludge" is the only method available. I don't know of an alternative/ better method either. I use it in combination with that other tab/ shift+tab "SendKeys" kludge we've discussed, to get focus onto a control when a form shows.

    <img src=/S/2cents.gif border=0 alt=2cents width=15 height=15>
    Alan

Posting Permissions

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