Solved

Delphi ListBox.setfocus problem...

Posted on 2003-11-19
7
942 Views
Last Modified: 2010-04-05
can anyone give me a source of a working listbox.setfocus command in delphi, because i always get array error.
thanks in advance :)
0
Comment
Question by:bbh2k3
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 9785057
??

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 ;-)
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 9787450
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.
0
 
LVL 2

Expert Comment

by:Robn
ID: 9788997
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.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:bbh2k3
ID: 9799885
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 .. ;)
0
 
LVL 2

Accepted Solution

by:
Robn earned 50 total points
ID: 9799915
Index := ListBox1.Items.Add(...);
ListBox1.ItemIndex := Index;
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 9800078
[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(...);



0
 

Author Comment

by:bbh2k3
ID: 9801709
thanks for the help guys, i really apriciate, keep it going!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question