![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I was thrilled to discover Stephen Leban's method of programmatically scrolling a list box -- http://www.lebans.com/List_Combo.htm#ScrollListbox My problem is, I want to scroll the list box as the user is typing into a text box. I'm using the text box's Change() event. The scrolling works, but it forces the list box to get the Focus. Of course this means that the user is interrupted after every character. I can give the focus back to the text box but the whole field is then selected and the cursor is not at the end of the field. |
#3
| |||
| |||
|
|
Try saving the text box's SelStart and SelLength properties before moving the focus and restoring them after the focus is returned to the text box. |
#4
| |||
| |||
|
#5
| |||
| |||
|
|
I was thrilled to discover Stephen Leban's method of programmatically scrolling a list box -- http://www.lebans.com/List_Combo.htm#ScrollListbox My problem is, I want to scroll the list box as the user is typing into a text box. I'm using the text box's Change() event. The scrolling works, but it forces the list box to get the Focus. Of course this means that the user is interrupted after every character. I can give the focus back to the text box but the whole field is then selected and the cursor is not at the end of the field. I suspect there is some way to declare an Alias to a Windows API that can restore the cursor to a given location in the text field? |
#6
| |||
| |||
|
#7
| |||
| |||
|
|
Thanks, Larry. That is indeed a more elegant solution. In my case it might not be ideal. The list box is there so the user can pick an existing value, which the user will do 99% of the time. The text box is there if the value isn't in the list, and the user needs to add it to the list. When the user is typing a new value, I want to scroll the list just to make doubly sure the user has looked to see whether the value isn't already in the list. The list needs to stay separate from the text box, because the user can do other things with the list entries, like click one and then edit it. I don't see a user-friendly way to do this with a combo box; either the user selects an item from the combo (meaning I should do X with the selection) or they add a new item (which I handle via NotInList). I need to do X, Y, or Z with the list box selection, so I'd better stick with the list box. But many thanks for the idea, which I'll probably use in the future. |
![]() |
| Thread Tools | |
| Display Modes | |
| |