Board index » delphi » Help da newbie ?!

Help da newbie ?!

Hey,
Is it possible when you click a button, a label will say the next item of a
listbox ?
Pls help me.
Dave
 

Re:Help da newbie ?!


Sure. Assume you have a TListBox called MyListBox, a TLabel called MyLabel
and an item variable called CurrentItem. Then, in the OnClick of the button:

    if CurrentItem > MyListBox.Items.Count then
        ShowMessage('At end of list.')
    else
    begin
        inc(CurrentItem);
        MyLabel.Caption := MyListBox.Items[CurrentItem - 1];
    end;

Start the CurrentItem variable at 0 before that first click to start at the
beginning of the list.

HTH
Woody

Quote
"David Mercurio" <mercurius.ger...@ping.be> wrote in message

news:8f6mti$rjg$1@news.planetinternet.be...
Quote
> Hey,
> Is it possible when you click a button, a label will say the next item of
a
> listbox ?
> Pls help me.
> Dave

Other Threads