stringgrid com maskara ???
Tenho uma stringrid e gostaria que na hora de digitar o campo numero ele saisse com a seguinte maskara 999.9 como faco isso ??? agradeco
Deusem
Curtidas 0
Respostas
Wbb
22/08/2003
É o seguinte: No evento OnKeyPress do StringGrid, escreva o código abaixo. Desta maneira, sempre que você escrever um número e teclar Enter ao terminar de escrever, o número será formatado como deseja.
procedure TForm1.StringGrid1KeyPress(Sender: TObject; var Key: Char);
Var Coluna, Linha: Integer;
begin
Coluna := StringGrid1.Col;
Linha := StringGrid1.Row;
if Key = #13 then
StringGrid1.Cells[Coluna,Linha] := FormatFloat(´0.0´, StrToFloat(StringGrid1.Cells[Coluna,Linha]));
end;
Dá pra melhorar a idéia ainda, mas isso já funciona.
wbb
procedure TForm1.StringGrid1KeyPress(Sender: TObject; var Key: Char);
Var Coluna, Linha: Integer;
begin
Coluna := StringGrid1.Col;
Linha := StringGrid1.Row;
if Key = #13 then
StringGrid1.Cells[Coluna,Linha] := FormatFloat(´0.0´, StrToFloat(StringGrid1.Cells[Coluna,Linha]));
end;
Dá pra melhorar a idéia ainda, mas isso já funciona.
wbb
GOSTEI 0
Rscrj
22/08/2003
Cara me manda seu e-mail que tenho isso pronto en casa e não chega a ser tantas linha de código.
GOSTEI 0