TIP: Click on subject to list as thread! ANSI
echo: delphi
to: JANNIEK HUMMELINK
from: CHRIS MANN
date: 1997-03-27 08:48:00
subject: Focus on listbox

On Mar 25 21:21 97, Janniek Hummelink of 2:285/264.2 wrote:
 JH> Hello All,
 JH> I encountered the following problem in Delphi 1.0 and 2.0:
 JH> (Borland Holland thought this was a bug ?!)
 JH> History :     I use a listbox in a scrollbox. During running the 
 JH> program, the listbox is
 JH> filled with strings of various lengthes. (The width 
 JH> and length of the listbox
 JH> is decided after investigating the strings).
 JH> Problem:    After you made a selection in the listbox and the focus 
 JH> is not on the listbox anymore, (you pressed a button or whatever)
 JH> the listbox items jump back to the top as soon as the listbox
 JH> gets the focus again.
 JH> Questions: -How can I prevent the listbox itemlist to jump to the top 
 JH> again, as soon as it gets the focus again?
 JH> -Or is there another elegant way to make a listbox 
 JH> without the 'top jump'?
I tried this with a listbox here and it work for me...
ListBox1 - OnExit event..
ListBox1.Tag := ListBox1.ItemIndex;  //save currently selected itemindex.
Wherever you come back to the listbox (setfocus maybe)..
ListBox1.TopIndex := ListBox1.Tag;  //make the saved itemindex the first in 
the list (scrolls to it) .
Hope this helps you out.
--- Msgedsq 2.2e
---------------
* Origin: Esc1.71 - When you're old enough to drive the bus. (1:157/534.30)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.