listbox question

Hi..

I have a listbox and a edit -line.
I enter a text in the edit -line, and it appears in the listbox.

After this, I want to automaticly select the listbox (done this) and select the text that I typed in the edit -box (highlight the text).

How can I make the listbox to do this 'auto' when I leave the edit -line?

I use Delphi Studio 2006...

Regards,
Roald - Norway.

Sorry my poor english...

Comments

  • : Hi..
    :
    : I have a listbox and a edit -line.
    : I enter a text in the edit -line, and it appears in the listbox.
    :
    : After this, I want to automaticly select the listbox (done this) and
    : select the text that I typed in the edit -box (highlight the text).
    :
    : How can I make the listbox to do this 'auto' when I leave the edit
    : -line?
    :
    : I use Delphi Studio 2006...
    :
    : Regards,
    : Roald - Norway.
    :
    : Sorry my poor english...
    :
    The TEdit.OnExit() event is thrown, whenever the focus shifts from one control to another. You can use this event to check if the focus shifts from the TEdit to another control.
  • : : Hi..
    : :
    : : I have a listbox and a edit -line.
    : : I enter a text in the edit -line, and it appears in the listbox.
    : :
    : : After this, I want to automaticly select the listbox (done this) and
    : : select the text that I typed in the edit -box (highlight the text).
    : :
    : : How can I make the listbox to do this 'auto' when I leave the edit
    : : -line?
    : :
    : : I use Delphi Studio 2006...
    : :
    : : Regards,
    : : Roald - Norway.
    : :
    : : Sorry my poor english...
    : :
    : The TEdit.OnExit() event is thrown, whenever the focus shifts from
    : one control to another. You can use this event to check if the focus
    : shifts from the TEdit to another control.




    I think you know what I mean, but I dont know what you mean...

    When I enter a string in edit -field, it copies the text into a listbox (this is ok).
    When this is done, I want to "select that 'string'" in listbox (that was entered in the listbox from the edit -line)

    If I enter 'Give me a beer'
    in edit -field, it copies in to listbox (all ok.)

    How can I automaticly select 'Give me a beer' in the Listbox?

  • : : : Hi..
    : : :
    : : : I have a listbox and a edit -line.
    : : : I enter a text in the edit -line, and it appears in the listbox.
    : : :
    : : : After this, I want to automaticly select the listbox (done this) and
    : : : select the text that I typed in the edit -box (highlight the text).
    : : :
    : : : How can I make the listbox to do this 'auto' when I leave the edit
    : : : -line?
    : : :
    : : : I use Delphi Studio 2006...
    : : :
    : : : Regards,
    : : : Roald - Norway.
    : : :
    : : : Sorry my poor english...
    : : :
    : : The TEdit.OnExit() event is thrown, whenever the focus shifts from
    : : one control to another. You can use this event to check if the focus
    : : shifts from the TEdit to another control.
    :
    :
    :
    :
    : I think you know what I mean, but I dont know what you mean...
    :
    : When I enter a string in edit -field, it copies the text into a
    : listbox (this is ok).
    : When this is done, I want to "select that 'string'" in listbox (that
    : was entered in the listbox from the edit -line)
    :
    : If I enter 'Give me a beer'
    : in edit -field, it copies in to listbox (all ok.)
    :
    : How can I automaticly select 'Give me a beer' in the Listbox?
    :
    :
    Here's the complete code for the TExit.OnExit():
    [code]
    procedure Form1.Edit1OnExit(Sender: TObject)
    var
    index: integer;
    begin
    index := ListBox1.Items.IndexOf(Edit1.Text);
    if (index > -1) and (Index < ListBox1.Items.Count) then
    ListBox1.ItemIndex := Index;
    end;
    [/code]
    Now if the user exits the edit box, then the item, which is typed in the editbox, is selected. This text must match perfectly, since it is case sensitive.
    Note: Names may need to be changed.
  • Thanks!
    This was exacly what I wanted.

    You are a genius! Thanks again! :-)
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories