Coisa Simples ---- ListBox

Delphi

03/12/2003

tenho uma listbox com 10 nomes...
como faço, para colocar apenas o nome q eu cliquei, em uma variavel..
qd eu tento... ele coloca todos os nomes da lista..
acho to usando o comando errado.. alguem ajuda ae please!!!


Robsondias

Robsondias

Curtidas 0

Respostas

Motta

Motta

03/12/2003

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;

type
TForm1 = class(TForm)
ListBox1: TListBox;
Label1: TLabel;
procedure ListBox1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.ListBox1Click(Sender: TObject);
begin
label1.caption := listbox1.items[listbox1.ItemIndex];
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
ListBox1.MultiSelect := False; {defina em desenho}
end;

end.


GOSTEI 0
Dedi

Dedi

03/12/2003

Amigo,
Faça assim
var MyVariavel:string;
begin
if listbox1.items.count > 0 then
MyVariavel:=listbox1.Items.Strings[listbox1.itemindex];
label1.caption:=MyVariavel;
end;




Dedi


GOSTEI 0
POSTAR