TListBox (Firemonkey) em tempo de execução
02/11/2014
0
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
Posts
05/04/2018
Jerrivaldo
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;
19/09/2018
Messias Galvão
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;
Clique aqui para fazer login e interagir na Comunidade :)