Link to home
Start Free TrialLog in
Avatar of bbh2k3
bbh2k3

asked on

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 :)
Avatar of kretzschmar
kretzschmar
Flag of Germany image

??

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

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

meikl ;-)
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.
Avatar of Robn
Robn

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.

Example
SetFocus(ListBox1.Handle);

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.
Avatar of bbh2k3

ASKER

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 .. ;)
ASKER CERTIFIED SOLUTION
Avatar of Robn
Robn

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
[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(...);



Avatar of bbh2k3

ASKER

thanks for the help guys, i really apriciate, keep it going!