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 :)
thanks in advance :)
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.
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.
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.
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.
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 .. ;)
sorry about my poor english .. ;)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
[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(...);
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(...);
ASKER
thanks for the help guys, i really apriciate, keep it going!
where is the problem?
maybe you should show what you do
procedure TForm1.Button1Click(Sender
begin
if listbox1.CanFocus then
listbox1.SetFocus;
end;
meikl ;-)