mascara no delphi 7
Amigos, estou tendo problemas com a mascara dos campos. Por exemplo: em um dbgrid que veio de clientdataset ou relatorio do quickreport através do qrdbtext, a data aparece 1/8/2012, e na verdade eu gostaria que aparecesse 01/08/2012. Ja fiz uma série de mudanças mas nada, inclusive o basico !99/99/0000;0. O Tedit tambem tenho problemas com valores, consegui colocar a formatação de valores, porem nao consigo alinhar a direita, sempre quando mostra o valor ele mostra alinhado a esquerda, e neste campo infelizmente não existe Alignment
Carlos Cabral
Curtidas 0
Respostas
Bruno Leandro
05/08/2012
voce precisa configurar no painel de controle / ( opções regionais de idioma ) ou ( regiões e idioma ) / formato de data abreviada
tem um função no delphi que voce pode verificar essa configuração se ShortDateFormat dd/MM/yyyy
tem um função no delphi que voce pode verificar essa configuração se ShortDateFormat dd/MM/yyyy
GOSTEI 0
Carlos Cabral
05/08/2012
Obrigado. Mas em relação ao Tedit ?
GOSTEI 0
Carlos Cabral
05/08/2012
como fazer alinhamento ao mostrar valores no Tedit
GOSTEI 0
William
05/08/2012
Carlos o componente TEdit POSSUI essa propriedade Alignment, já o componente TDBEdit NÃO possui essa propriedade mas pode se alinhar o texto usando os campos do DataSet.
GOSTEI 0
Carlos Cabral
05/08/2012
Eu estou meio perdido com algumas coisas, no meu Object Inspector, Propriedades não tenho o Alignment, estou usando o delphi 7, e sou muito novato, talvez nao tenha entendido o que voce disse.
GOSTEI 0
Deivison Melo
05/08/2012
A property mencionada é de visibilidade privada...
Verifique se essas funções abaixo atenderão vc:
Como centralizar um texto num edit?
Abaixo segue duas funções
{Centraliza uma string em um espaço determinado}
function PadC(S:string;Len:byte):string;
var
Str:String;
L:byte;
begin
str :=;
if len Length(s) then
begin
Result := ;
Exit;
end;
l:=(Len-Length(S)) div 2;
while l 0 do
begin
str:=str+ ;
dec(l);
end;
for l:=1 to length(S) do
begin
str := str+s[L];
end;
Result := str;
end;
{Alinha uma string em um determinado espaço}
function AlinharStr(Pe_Str:string; Pe_QtdPos:Byte; EDC :Char):string;
// EDC: C = Centralizado
// D = Direita
// E = Esquerda
var
L, N, R, I :integer;
S, St, CH :string;
begin
i := Pe_qtdPos;
St := copy(Pe_Str,1,Pe_QtdPos);
if EDC = D then
begin
Insert(aLeX,St,i);
L := Pos(aLeX,St);
if L = i then
begin
for n := L to i do
begin
Insert( , St, 1);
end;
end;
St := Copy(St,1,i);
R := i;
Ch := Copy(St,i,1);
while (Ch = ) and (R 0) do
begin
if ch = then
begin
Insert( , St, 1);
end;
St := Copy(St, 1, i);
R := R - 1;
Ch := Copy(St, i, 1);
end;
end;
if EDC = E then
begin
Ch := Copy(St,1,1);
while Ch = do
begin
Delete(St,1,1);
Ch := Copy(St,1,1);
end;
St := Copy(St,1,i);
end;
if EDC = C then
begin
S := AlinharStr(Pe_Str,Pe_QtdPos,D);
Ch := Copy(S,1,1);
R := 1;
N := 1;
while Ch = do
begin
R := R + 1;
Ch := Copy(S,R,1);
end;
R := Round( R / 2 );
while n R do
begin
Delete(S,1,1);
N := N + 1;
end;
St := Copy(S,1,i);
end;
AlinharStr := St;
end;
Verifique se essas funções abaixo atenderão vc:
Como centralizar um texto num edit?
Abaixo segue duas funções
{Centraliza uma string em um espaço determinado}
function PadC(S:string;Len:byte):string;
var
Str:String;
L:byte;
begin
str :=;
if len Length(s) then
begin
Result := ;
Exit;
end;
l:=(Len-Length(S)) div 2;
while l 0 do
begin
str:=str+ ;
dec(l);
end;
for l:=1 to length(S) do
begin
str := str+s[L];
end;
Result := str;
end;
{Alinha uma string em um determinado espaço}
function AlinharStr(Pe_Str:string; Pe_QtdPos:Byte; EDC :Char):string;
// EDC: C = Centralizado
// D = Direita
// E = Esquerda
var
L, N, R, I :integer;
S, St, CH :string;
begin
i := Pe_qtdPos;
St := copy(Pe_Str,1,Pe_QtdPos);
if EDC = D then
begin
Insert(aLeX,St,i);
L := Pos(aLeX,St);
if L = i then
begin
for n := L to i do
begin
Insert( , St, 1);
end;
end;
St := Copy(St,1,i);
R := i;
Ch := Copy(St,i,1);
while (Ch = ) and (R 0) do
begin
if ch = then
begin
Insert( , St, 1);
end;
St := Copy(St, 1, i);
R := R - 1;
Ch := Copy(St, i, 1);
end;
end;
if EDC = E then
begin
Ch := Copy(St,1,1);
while Ch = do
begin
Delete(St,1,1);
Ch := Copy(St,1,1);
end;
St := Copy(St,1,i);
end;
if EDC = C then
begin
S := AlinharStr(Pe_Str,Pe_QtdPos,D);
Ch := Copy(S,1,1);
R := 1;
N := 1;
while Ch = do
begin
R := R + 1;
Ch := Copy(S,R,1);
end;
R := Round( R / 2 );
while n R do
begin
Delete(S,1,1);
N := N + 1;
end;
St := Copy(S,1,i);
end;
AlinharStr := St;
end;
GOSTEI 0
William
05/08/2012
Pessoal estou usando o Delphi XE, agora acho muito estranho no Delphi 7 essa propriedade ser privada (TEdit), pois não requer habilidade de POO, pois a mesma está vísivel no Object Inspector e pode ser alterada sem maiores problemas..
GOSTEI 0