Autopreenchimento
Boa tarde caros colegas,
Tenho dois GroupBox, com 30 Edits em cada um deles. Preciso preencher com o Caracter "0" (zero) os edits que não forem preenchidos. Como posso automatizar esta situação??
Alguém aí pode me dar esta dica???
Tenho dois GroupBox, com 30 Edits em cada um deles. Preciso preencher com o Caracter "0" (zero) os edits que não forem preenchidos. Como posso automatizar esta situação??
Alguém aí pode me dar esta dica???
Aloisio Santos
Curtidas 0
Respostas
Jones Granatyr
23/12/2016
Opa! Você pode fazer assim
for I := 0 to ComponentCount-1 do
begin
if (Components[I] is TEdit) then
TEdit(Components[I]).Text := '';
end;
for I := 0 to ComponentCount-1 do
begin
if (Components[I] is TEdit) then
TEdit(Components[I]).Text := '';
end;
GOSTEI 0
Aloisio Santos
23/12/2016
Opa! Você pode fazer assim
for I := 0 to ComponentCount-1 do
begin
if (Components[I] is TEdit) then
TEdit(Components[I]).Text := '';
end;
for I := 0 to ComponentCount-1 do
begin
if (Components[I] is TEdit) then
TEdit(Components[I]).Text := '';
end;
Vlw Jones, porém, preciso de algo mais específico.
Esta rotina funciona em partes. Eu preciso que sejam preenchidos com Zero, apenas os edits que não apresentem conteúdo.
GOSTEI 0
Raimundo Pereira
23/12/2016
Boa tarde, seguindo o que já temos faça assim
public
{ Public declarations }
Function ValidarEdits(Novo_Valor:string):string;
implementation
{$R *.dfm}
Function TForm1.ValidarEdits(Novo_Valor:string):string;
var i:integer;
begin
for I := 0 to ComponentCount-1 do
begin
if (Components[I] is TEdit) then
begin
if (TEdit(Components[I]).Text = '') then
begin
TEdit(Components[I]).Text := Novo_Valor;
end;
end;
end;
end;
end.
Para chamar a validação faça
procedure TForm1.Btn_ValidarClick(Sender: TObject);
begin
ValidarEdits('0');// Onde 0 é o valor escolhido
end;
public
{ Public declarations }
Function ValidarEdits(Novo_Valor:string):string;
implementation
{$R *.dfm}
Function TForm1.ValidarEdits(Novo_Valor:string):string;
var i:integer;
begin
for I := 0 to ComponentCount-1 do
begin
if (Components[I] is TEdit) then
begin
if (TEdit(Components[I]).Text = '') then
begin
TEdit(Components[I]).Text := Novo_Valor;
end;
end;
end;
end;
end.
Para chamar a validação faça
procedure TForm1.Btn_ValidarClick(Sender: TObject);
begin
ValidarEdits('0');// Onde 0 é o valor escolhido
end;
GOSTEI 0
Aloisio Santos
23/12/2016
Boa tarde, seguindo o que já temos faça assim
public
{ Public declarations }
Function ValidarEdits(Novo_Valor:string):string;
implementation
{$R *.dfm}
Function TForm1.ValidarEdits(Novo_Valor:string):string;
var i:integer;
begin
for I := 0 to ComponentCount-1 do
begin
if (Components[I] is TEdit) then
begin
if (TEdit(Components[I]).Text = '') then
begin
TEdit(Components[I]).Text := Novo_Valor;
end;
end;
end;
end;
end.
Para chamar a validação faça
procedure TForm1.Btn_ValidarClick(Sender: TObject);
begin
ValidarEdits('0');// Onde 0 é o valor escolhido
end;
public
{ Public declarations }
Function ValidarEdits(Novo_Valor:string):string;
implementation
{$R *.dfm}
Function TForm1.ValidarEdits(Novo_Valor:string):string;
var i:integer;
begin
for I := 0 to ComponentCount-1 do
begin
if (Components[I] is TEdit) then
begin
if (TEdit(Components[I]).Text = '') then
begin
TEdit(Components[I]).Text := Novo_Valor;
end;
end;
end;
end;
end.
Para chamar a validação faça
procedure TForm1.Btn_ValidarClick(Sender: TObject);
begin
ValidarEdits('0');// Onde 0 é o valor escolhido
end;
Vlw Jones... deu certo...
Agora só vou ter que adaptar para o que de fato eu quero aqui... Muito obrigado.
POST RESOLVIDO.
GOSTEI 0