Connecting Tech Pros Worldwide Forums | Help | Site Map

Update the value property of a textbox without losing the focus?

Newbie
 
Join Date: Aug 2008
Location: Cambridge
Posts: 13
#1: Sep 2 '08
Hi, I'm creating a "Filter-as-you-type" feature.
The problem is: when a textbox is being keyed in, only the Text property changes but the Value property, which I want to use, doesn't.
The only solution I found is to set the focus to another control and hence causes the update.
However, if I use this method, The function will end with the text in the box I have just typed in highlighted.
Then you will see that this is not much of the "Filter-as-you-type" I hoped because the user have to press 'end button' in order to continue his typing.

Any ideas? thanks,
Billiska

Newbie
 
Join Date: Aug 2008
Location: Cambridge
Posts: 13
#2: Sep 2 '08

re: Update the value property of a textbox without losing the focus?


To: Whoever read this thread.

I have figured it out.
I just check if one of the controls has the focus when the filtering has to be performed. Then just write obj.value = obj.text if it is a textbox (if instead it is a combobox, this might a little bit more compolicated.)

However, the text inside the search box will still be highlighted anyway because of requerying or whatever.
This can be solved by putting the search boxes on a main form and using a subform to display the records. Hence, only the subform need to be requeried.

...If anybody has a better way to do this, let's share it. thanks
FishVal's Avatar
Expert
 
Join Date: Jun 2007
Location: Israel
Posts: 2,584
#3: Sep 2 '08

re: Update the value property of a textbox without losing the focus?


Hello, Billiska.
  • What is wrong with retrieving textbox content via Text property, why do you need TextBox.Value to be changed?
  • You may use TextBox.SelStart and TextBox.SelLength properties to manipulate TextBox current selection and/or cursor position.

Regards,
Fish
Reply