Solved

Delphi ListBox.setfocus problem...

Posted on 2003-11-19
7
950 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

Independent Software Vendors: 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!

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

696 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