Dissapearing spaces, and recursive loops(changed event)

G

Guest

Good morning

I am currently working on a program that is basically a search threw a
recordset. It gives the user a display of the records that con be scrolled
threw and a text box, or check box for each field to search threw. The search
gets activated in the changed event of the boxes and basically builds a
complete recordset and deletes from the recordset all the records that don't
match. Doing this I have built a search that updates on every keystroke and
searches multiple records at once.

The problem is that in the module when I access the other fields I must
set focus to them to get at there text, quickly setting focus back to the
original text box there after, except that when you type a Space, it trims it
off after loss of focus resulting in not being able to use spaces in the
search as it simply disappears right after you enter it.

I have already tried to check for a space before the loss of focus and
add one after if there was one, but that creates an infinite recursive loop,
as the function keeps calling it's self when the text changes.

If anyone knows of a way to turn off this auto-trim, or maybe make the
changed event not fire when you manually change the text box that would be
very helpful.

- Alex
 
C

ChrisM

- Alex said:
Good morning

I am currently working on a program that is basically a search threw a
recordset. It gives the user a display of the records that con be scrolled
threw and a text box, or check box for each field to search threw. The
search
gets activated in the changed event of the boxes and basically builds a
complete recordset and deletes from the recordset all the records that
don't
match. Doing this I have built a search that updates on every keystroke
and
searches multiple records at once.

The problem is that in the module when I access the other fields I
must
set focus to them to get at there text, quickly setting focus back to the
original text box there after, except that when you type a Space, it trims
it
off after loss of focus resulting in not being able to use spaces in the
search as it simply disappears right after you enter it.

I have already tried to check for a space before the loss of focus and
add one after if there was one, but that creates an infinite recursive
loop,
as the function keeps calling it's self when the text changes.

If anyone knows of a way to turn off this auto-trim, or maybe make the
changed event not fire when you manually change the text box that would be
very helpful.

- Alex

Hi Alex,

Not sure if I totally understand the problem, but one way to accomplish what
you say at the end would be do declare a global bool variable called
somthing like changingText.

Then you could say:

changingText = true;
myTextBox.Text = myTextBox.Text + " ";
changingText = false;

In the Text_Changed event, you could have:

if (changingText)
Return;
else
<current Text_Changed code goes here>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top