Solved

Delphi ListBox.setfocus problem...

Posted on 2003-11-19
7
919 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
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 27

Expert Comment

by:kretzschmar
Comment Utility
??

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
Comment Utility
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
Comment Utility
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Author Comment

by:bbh2k3
Comment Utility
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
Comment Utility
Index := ListBox1.Items.Add(...);
ListBox1.ItemIndex := Index;
0
 
LVL 26

Expert Comment

by:EddieShipman
Comment Utility
[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
Comment Utility
thanks for the help guys, i really apriciate, keep it going!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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 this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

743 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now