Hello All,
I encountered the following problem in Delphi 1.0 and 2.0:
(Borland Holland thought this was a bug ?!)
History : I use a listbox in a scrollbox. During running the program, the
listbox is
filled with strings of various lengthes. (The width and
length of the listbox
is decided after investigating the strings).
Problem: After you made a selection in the listbox and the focus is not
on the listbox anymore, (you pressed a button or whatever)
the listbox items jump back to the top as soon as the
istbox
gets the focus again.
Questions: -How can I prevent the listbox itemlist to jump to the top again,
as soon as it gets the focus again?
-Or is there another elegant way to make a listbox without
the 'top jump'?
Unit ListBox;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Show_Button: TButton;
ScrollBox: TScrollBox;
ListBox: TListBox;
Choosen_Label: TLabel;
procedure Show_ButtonClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
var
n : integer;
begin
ListBox.Height := 50 * ListBox.ItemHeight;
for n:= 1 to 50 do ListBox.Items.Add(IntToStr(n));
end;
procedure TForm1.Show_ButtonClick(Sender: TObject);
begin
Choosen_Label.Caption := (ListBox.Items[ListBox.ItemIndex]);
end;
End.
---
---------------
* Origin: Mijn computer is uitgeDOSt met Windows 95... (2:285/264.2)
|