Fórum Máscara em célula no DBGrid #375065
18/09/2009
0
Tenho uma unit para mascarar campos como: CPF. CNPJ, Data, ...
para usar faço o seguinte:
procedure TFormCliente.DBEDataKeyPress(Sender: TObject; var Key: Char);
begin
Mascara_Data(Key, Sender);
end;
O problema começa em como faço para utilizar esta máscara em um campo no DBGrid? Pois do DBGrid eu digito os dados.
No DBGrid coloco desta maneira, só que não acontece nada quando digito a data.
procedure TFormOrcamento.DBGProdutosKeyPress(Sender: TObject;
var Key: Char);
begin
If DBGProdutos.SelectedField.FieldName = ´PRAZOENTREGA_OIT´ then
begin
If ADOQOrcamentoItensF.State in [dsEdit, dsInsert] then
Mascara_Data(Key, Sender);
end;
end;
Desde já agradeço a atenção companheiros.
Leufmt
Curtir tópico
+ 0Posts
18/09/2009
Leufmt
function Mascara_Data(var Key: char; Sender: TObject): String;
begin
If not(Key in[´0´..´9´, #8, 13]) then
Key := 0;
If Key <> 8 then
begin
Case Length(TCustomEdit(Sender).Text) of
2: begin
If not (Key in [´0´..´9´]) then
Key := 0;
TCustomEdit(Sender).Text := TCustomEdit(Sender).Text + ´/´;
TCustomEdit(Sender).SelStart := Length(TCustomEdit(Sender).Text);
end;
5: begin
If not (Key in [´0´..´9´]) then
Key := 0;
TCustomEdit(Sender).Text := TCustomEdit(Sender).Text + ´/´;
TCustomEdit(Sender).SelStart := Length(TCustomEdit(Sender).Text);
end;
end;
end;
end;
Gostei + 0
18/09/2009
Marco Salles
para isto... ???
Gostei + 0
19/09/2009
Dbergkamps10
leufmt, vc pode mascarar direto na propriedade EditMask no campo do Data Set, através do objetc inspector.
Espero ter ajudado.
Att
Dalton
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)