Fórum TListBox (Firemonkey) em tempo de execução #499925
02/11/2014
0
Olá Pessoal!
Estou tentando criar items customizados para um TListBox em tempo de execução.
Estou fazendo conforme abaixo:
Os item são criados e mostrados no listBox1 porém não consigo selecioná-lo...
Alguém teria um exemplo mais completo de como fazer isso? Desejo fazer um listBox cutomizado...
Estou tentando criar items customizados para um TListBox em tempo de execução.
Estou fazendo conforme abaixo:
var
item : TListBoxItem;
texto : TText;
begin
listBox1.HitTest := true;
listBox1.Items.Add('');
item := listBox1.ListItems[listBox1.Items.Count-1];
item.HitTest := true;
texto := TText.create(nil);
texto.Text := 'Teste 01';
texto.HorzTextAlign := TTextAlign.taLeading;
texto.VertTextAlign := TTextAlign.taLeading;
texto.color := TAlphaColors.Black;;
texto.parent := item;
texto.Align := TAlignLayout.alClient;
listBox1.Items.Add('');
item := listBox1.ListItems[listBox1.Items.Count-1];
item.HitTest := true;
texto := TText.create(nil);
texto.Text := 'Teste 02';
texto.HorzTextAlign := TTextAlign.taLeading;
texto.VertTextAlign := TTextAlign.taLeading;
texto.color := TAlphaColors.Black;;
texto.parent := item;
texto.Align := TAlignLayout.alClient;
Os item são criados e mostrados no listBox1 porém não consigo selecioná-lo...
Alguém teria um exemplo mais completo de como fazer isso? Desejo fazer um listBox cutomizado...
Carlos Phelippe
Curtir tópico
+ 0
Responder
Posts
05/04/2018
Jerrivaldo
Faz assim:
procedure TForm7.FormCreate(Sender: TObject);
var
ListBoxItem: TListBoxItem;
begin
with TListBoxItem.Create(ListBox1) do
begin
Size.Width := 388;
Size.Height := 50;
Size.PlatformDefault := False;
Text := 'Testando';
Visible := True;
Parent := ListBox1;
end;
end;
procedure TForm7.FormCreate(Sender: TObject);
var
ListBoxItem: TListBoxItem;
begin
with TListBoxItem.Create(ListBox1) do
begin
Size.Width := 388;
Size.Height := 50;
Size.PlatformDefault := False;
Text := 'Testando';
Visible := True;
Parent := ListBox1;
end;
end;
Responder
Gostei + 0
19/09/2018
Messias Galvão
Só Complementando:
Var
ListBoxItem: TListBoxItem;
begin
ListBoxItem:= TListBoxItem.Create(ListBox1);
with ListBoxItem do
begin
Size.Width := 388;
Size.Height := 50;
Size.PlatformDefault := False;
Text := 'Banco do Brasil';
ItemData.Detail:= '0800 729 0722'; //Acrescenta um segundo item
ItemData.Accessory:= TListBoxItemData.TAccessory(3); //Efeito check
StyleLookup := 'listboxitembottomdetail'; // Listbox detalhado
Visible := True;
Parent := ListBox1;
end;
end;
Var
ListBoxItem: TListBoxItem;
begin
ListBoxItem:= TListBoxItem.Create(ListBox1);
with ListBoxItem do
begin
Size.Width := 388;
Size.Height := 50;
Size.PlatformDefault := False;
Text := 'Banco do Brasil';
ItemData.Detail:= '0800 729 0722'; //Acrescenta um segundo item
ItemData.Accessory:= TListBoxItemData.TAccessory(3); //Efeito check
StyleLookup := 'listboxitembottomdetail'; // Listbox detalhado
Visible := True;
Parent := ListBox1;
end;
end;
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)