0
I am using the following code to make Checkbox visible.
CheckBox: Array[1..15] of TcheckBox;
procedure TForm1.edt_variavelChange(Sender: TObject);
var valor,x,i : integer;
if valor = 2 then
begin
for i := 1 to 2 do
begin
TEdit(FindComponent('edt_variavel'+IntToStr(i))).Visible := true
CheckBox[i].Visible := true;
end;
but he gives a Acess Violation
, when using debug and giving a BREAK
in the error I am directed to this code of Vcl.Controls
procedure TControl.SetVisible(Value: Boolean);
begin
if FVisible <> Value then
begin
VisibleChanging;
FVisible := Value;
Perform(CM_VISIBLECHANGED, Ord(Value), 0);
RequestAlign;
end;
end;
How can I fix this error?
Checkbox esitem, are components created? It would not be the case to perform component search and so set?
– Luiz Vichiatto
Paste the entire code
– Passella
They exist, they are only set to invisible. @Passella what most needs the code? I think all the information is there.
– Guilherme Lima
try: if Assigned(Checkbox[i]) then Checkbox[i]. Visible := True;
– Passella
nothing happens @Passella
– Guilherme Lima
passes the entire code, it’s easier for someone to give you an answer
– Passella
added @Passella
– Guilherme Lima
Voce does not guarantee that its local variable value is 2, Voce did not set the objects in the Checkbox vector, check whether the Findcomponent method actually returns anything, I hope it has helped
– Passella
Returns because edits become visible, and the event is in the onchange so by adding 2 in the variable value, 2 edits become visible, and the same should be repeated for checkboxes.
– Guilherme Lima