Remove part of a text in the combobox

1

I have a combobox that I read a directory and bring the names of the files found:

output:

demons.txt 
arch.txt 
elo.txt

So far so good, but I do not want the combobox to appear in .txt , how do you remove it?

    
asked by anonymous 09.08.2016 / 18:42

1 answer

1

You can use the TPath.GetFileNameWithoutExtension function:

Uses
  IOUtils;
// ....

procedure TForm1.FormCreate(Sender: TObject);
const
   Arquivos: array[1..3] of string = ('demons.txt ','arch.txt ','elo.txt');
Var
   Arquivo: String;
begin
  ComboBox1.Clear;
  For Arquivo in Arquivos do 
  begin
    ComboBox1.Items.Add(TPath.GetFileNameWithoutExtension(Arquivo));
  end;
end;
    
09.08.2016 / 18:59