Delphi ListBox.setfocus problem...

can anyone give me a source of a working listbox.setfocus command in delphi, because i always get array error.
thanks in advance :)
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


where is the problem?
maybe you should show what you do

procedure TForm1.Button1Click(Sender: TObject);
  if listbox1.CanFocus then

meikl ;-)
Eddie ShipmanAll-around developerCommented:
You are getting an array error? It is NOT coming from the listbox because Listbox deosn't use arrays.
If you post the code you are using and the COMPLETE error message, we can help you.
I have never seen this problem before but I have had issues where SetFocus causes errors (especially on 3rd party components in ActiveX forms) and I solved this by using SetFocus in the Windows unit.


However, like EddieShipman said, this seems to be something other than a SetFocus error. The ListBox will use arrays in the OS to manage the items but I have never seen this error in Delphi before.
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

bbh2k3Author Commented:
i wanted to do it like, when i add a line in the listbox, to automatically scoll down the bar to see the line added.
sorry about my poor english .. ;)
Index := ListBox1.Items.Add(...);
ListBox1.ItemIndex := Index;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Eddie ShipmanAll-around developerCommented:
[quote]when i add a line in the listbox, to automatically scoll down the bar to see the line added[/quote]

What would that have to do with setting focus to the listbox, anyway?

Robn gave you the correct answer to do that but it can be shortened to:

ListBox1.ItemIndex := ListBox1.Items.Add(...);

bbh2k3Author Commented:
thanks for the help guys, i really apriciate, keep it going!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.