Fórum Inserir Tabulação ListBox #502192
24/11/2014
0
Estou tentando inserir tabulação em um Listbox para deixar formatado a String para não ficar bagunçado o texto, porém apesar de na string aparecer o #9 como tabulação, no list box visualmente não aparece a tabulação.
procedure TFTipoEntrega.FormShow(Sender: TObject);
var
lTexto : String;
function FormatarTexto(pTexto: String):String;
var
lTexto: String;
lCont : Integer;
begin
lTexto := pTexto;
for lCont := Length(pTexto) to 25 do
begin
lTexto := lTexto + ' ';
end;
result := lTexto;
end;
begin
FConfirma := false;
lstTipoEntrega.Items.Clear;
FConsulta_Balcao.Calcular_Frete_Prevenda.First;
while not(FConsulta_Balcao.Calcular_Frete_Prevenda.Eof) do
begin
lTexto := 'Tipo Entrega: ' + FConsulta_Balcao.Calcular_Frete_PrevendaTIPO_SLA.AsString + #9 + #9 +
' - R$ ' + FormatFloat('0.00',FConsulta_Balcao.Calcular_Frete_PrevendaFRETE.AsFloat);
lstTipoEntrega.Items.Add(lTexto);
FConsulta_Balcao.Calcular_Frete_Prevenda.Next;
end;
end;
[img]http://arquivo.devmedia.com.br/forum/imagem/341795-20141124-105818.png[/img]
[img]http://arquivo.devmedia.com.br/forum/imagem/341795-20141124-105844.png[/img]
Lucas Ramos
Curtir tópico
+ 0Post mais votado
24/11/2014
Quando precisei de situações semelhantes, utilizei no listbox a fonte "Courier New" que possui espaçamento igual para todas as letras e completei a diferença entre os textos com espaços.
ListBox1.Items.Add('Tipo Entrega: CORREIOS' + Copy(' ',1,10-Length('CORREIOS')) + ' - R$ 10,00');
ListBox1.Items.Add('Tipo Entrega: PAC' + Copy(' ',1,10-Length('PAC')) + ' - R$ 15,00');
ListBox1.Items.Add('Tipo Entrega: MOTOBOY' + Copy(' ',1,10-Length('MOTOBOY')) + ' - R$ 0,00');
Abraççç,
rrubinho
Renato Rubinho
Gostei + 1
Mais Posts
24/11/2014
Lucas Ramos
Gostei + 0
24/11/2014
Lucas Ramos
Já tenho uma função que ta no código que preenche com espaços a direita, vou verificar com essa fonte e testar para ver, obrigado.
Gostei + 0
24/11/2014
Lucas Ramos
procedure TFTipoEntrega.FormShow(Sender: TObject);
var
lTexto : String;
function FormatarTexto(pTexto: String):String;
var
lTexto: String;
lCont : Integer;
begin
lTexto := pTexto;
for lCont := Length(pTexto) to 25 do
begin
lTexto := lTexto + ' ';
end;
result := lTexto;
end;
begin
FConfirma := false;
lstTipoEntrega.Items.Clear;
FConsulta_Balcao.Calcular_Frete_Prevenda.First;
while not(FConsulta_Balcao.Calcular_Frete_Prevenda.Eof) do
begin
lTexto := 'Tipo Entrega: ' + FConsulta_Balcao.Calcular_Frete_PrevendaTIPO_SLA.AsString;
lTexto := FormatarTexto(lTexto) +
' - R$ ' + FormatFloat('0.00',FConsulta_Balcao.Calcular_Frete_PrevendaFRETE.AsFloat);
lstTipoEntrega.Items.Add(lTexto);
FConsulta_Balcao.Calcular_Frete_Prevenda.Next;
end;
lstTipoEntrega.ItemIndex := 0;
end;
[img]http://arquivo.devmedia.com.br/forum/imagem/341795-20141124-120920.png[/img]
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)