Board index » delphi » ListBox question

ListBox question

I have a question:

Is it possible to scroll up the contents of a ListBox when i use
ListBox.items.Add so that I don't have to use the scrollbar to scroll down
with my mouse when the data doesn't fit in the ListBox ?
When i use ListBox.Items.Add the new data should appear on the bottom line
of the ListBox, the rest of the text
must scroll up.

please also send a copy of your answer to my email-address.

Thanks!

Erwin.

* Please remove REMOVETHIS from my email-address *

 

Re:ListBox question


You can use ItemIndex property to select the last component in
the list, then each time you add something you will have your
last component selected. Code should look something like this

ListBox1.Items.Add('Hello World');
ListBox1.ItemIndex := ListBox1.Items.Count;

By the way, do you know any good color coding routine?

Bye, Groman.

Quote
Erwin Konings wrote:

> I have a question:

> Is it possible to scroll up the contents of a ListBox when i use
> ListBox.items.Add so that I don't have to use the scrollbar to scroll down
> with my mouse when the data doesn't fit in the ListBox ?
> When i use ListBox.Items.Add the new data should appear on the bottom line
> of the ListBox, the rest of the text
> must scroll up.

> please also send a copy of your answer to my email-address.

> Thanks!

> Erwin.

Re:ListBox question


The code presented below by mr. Golitsin would not work properly, since
ItemIndex starts at 0, and Items.Count start at 1...
Try: ListBox1.ItemIndex:=ListBox1.Items.Count-1;
I am having a similar problem, and have got the scrolling ok, but my problem is
that when I have two entries with the same value, the focus is set on the first
of them, not the last, as I want. Any suggestions??
(I am using Delphi 1.0)

FB

Quote
Vladimir Golitsin wrote:
> You can use ItemIndex property to select the last component in
> the list, then each time you add something you will have your
> last component selected. Code should look something like this

> ListBox1.Items.Add('Hello World');
> ListBox1.ItemIndex := ListBox1.Items.Count;

> By the way, do you know any good color coding routine?

> Bye, Groman.

> Erwin Konings wrote:

> > I have a question:

> > Is it possible to scroll up the contents of a ListBox when i use
> > ListBox.items.Add so that I don't have to use the scrollbar to scroll down
> > with my mouse when the data doesn't fit in the ListBox ?
> > When i use ListBox.Items.Add the new data should appear on the bottom line
> > of the ListBox, the rest of the text
> > must scroll up.

> > please also send a copy of your answer to my email-address.

> > Thanks!

> > Erwin.

Other Threads