Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Dissapearing spaces, and recursive loops(changed event)

Discussion in 'Information Technology' started by - Alex, Jul 28, 2006.

  1. - Alex

    - Alex
    Expand Collapse
    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
     
  2. Loading...

    Similar Threads Forum Date
    Sikhi Gurdwaras Throw Open Their Spaces, Langar For Stranded Commuters In Haryana Sikh Sikhi Sikhism Feb 23, 2016
    Sikh News Want a ride in spaceship? Pay Rs 1.10 cr (Sify News) Breaking News May 30, 2005
    Sikh News Want a ride in spaceship? It's just Rs 11 mn (Press Trust of India) Breaking News May 30, 2005

  3. ChrisM

    ChrisM
    Expand Collapse
    Guest

    "- Alex" <Alex@discussions.microsoft.com> wrote in message
    news:B2BA2F0A-E4A7-41E0-949D-1EA7F7EB9BFA@microsoft.com...
    > 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>
     
  4. - Alex

    - Alex
    Expand Collapse
    Guest

    Pure simple Genius, thank you very much sir thats exactly what I needed.

    "ChrisM" wrote:

    >
    > "- Alex" <Alex@discussions.microsoft.com> wrote in message
    > news:B2BA2F0A-E4A7-41E0-949D-1EA7F7EB9BFA@microsoft.com...
    > > 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>
    >
    >
    >
     

Share This Page