Board index » delphi » TComboBox

TComboBox

Hi,

    I have a TComboBox on my form and I add strings to it based on the
lastname that was entered (displays all firstnames associated with
lastname).  This works, however, I am using the OnKeyUp event on my
lastname edit box otherwise it leaves out the last character until I
press another key ( like OnKeyPress ).  The problem is that for some
reason, it displays the second string (string[1]) twice and every
other one just the one time.  When I debug and step through the loop,
it only goes through the appropriate number of times, and displays the
correct amount of names afterwards, but only if I debug and step
through.  Does anybody know what might be causing this?

Thanks in advance
Ghost

 

Re:TComboBox


Quote
"Ghost" <jeremy_gilbe...@hotmail.com> wrote in message

news:55f559cc.0306180619.159b4b80@posting.google.com...

Quote
> Hi,

>     I have a TComboBox on my form and I add strings to it based on the
> lastname that was entered (displays all firstnames associated with
> lastname).  This works, however, I am using the OnKeyUp event on my
> lastname edit box otherwise it leaves out the last character until I
> press another key ( like OnKeyPress ).  The problem is that for some
> reason, it displays the second string (string[1]) twice and every
> other one just the one time.  When I debug and step through the loop,
> it only goes through the appropriate number of times, and displays the
> correct amount of names afterwards, but only if I debug and step
> through.  Does anybody know what might be causing this?

OnChange might be a better event to use, but it can be trickier. This event
is fired whenever the contents of the edit changes. The advantage of this is
that cut and paste operations will also trigger the event. As to your real
problem, without seeing at least the outline of the code that fills the
combobox its really quite difficult to guess what you are doing wrong.
Although I will say that if you are stepping through a table or query of
first names, you might check your loop termination test to insure that it is
indeed terminating the loop at the appropriate time.

Other Threads