I am trying to dynamically create an array of components in a ScrollBox all of the components are being created and displayed correctly except the SpinEdit component. What am I doing wrong???
Here is a snippet of the code creating the components.
EventRec^.fDesc := TLabel.Create(Form17.ScrollBox1);
with EventRec^.fDesc do begin
Parent := Form17.ScrollBox1;
Name := 'lblDesc' + IntToStr(i);
Caption := VarToStr(Fields[0].Value);
Left := XPos[0];
Top := YPos;
Width := XWid[0];
WordWrap := True;
AutoSize := False;
if Canvas.TextWidth(Caption) > Width then begin
txtWid := Canvas.TextWidth(Caption);
if txtWid mod Width = 0 then Addon := 0
else Addon := 1;
Height := 16 * ((txtWid div Width) + Addon);
end else
Height := 21;
YInc := Height + 3;
end;
EventRec^.fUnit := TEdit.Create(Form17.ScrollBox1);
with EventRec^.fUnit do begin
Parent := Form17.ScrollBox1;
Name := 'txtUnit' + IntToStr(i);
Text := RealToStr(StrToReal(Fields[1].Value), 2);
Left := XPos[1];
Top := YPos;
Width := XWid[1];
Height := 21;
ReadOnly := True;
end;
EventRec^.fQty := TSpinEdit.Create(Form17.ScrollBox1);
with EventRec^.fQty do begin
Name := 'spnQty' + IntToStr(i);
Min := 0;
Max := 4;
Value := 0;
Left := XPos[2];
Top := YPos;
Width := XWid[2];
Height := 21;
OnClick := Dummy.SpinEditChange;
end;
EventRec^.fValue := TEdit.Create(Form17.ScrollBox1);
with EventRec^.fValue do begin
Parent := Form17.ScrollBox1;
Name := 'txtValue' + IntToStr(i);
Text := '0.00';
Top := YPos;
Left := XPos[3];
Width := XWid[3];
Height := 21;
ReadOnly := True;
end;
EvtObjList.Add(EventRec);
YPos := YPos + YInc;
Here is a snippet of the code creating the components.
EventRec^.fDesc := TLabel.Create(Form17.ScrollBox1);
with EventRec^.fDesc do begin
Parent := Form17.ScrollBox1;
Name := 'lblDesc' + IntToStr(i);
Caption := VarToStr(Fields[0].Value);
Left := XPos[0];
Top := YPos;
Width := XWid[0];
WordWrap := True;
AutoSize := False;
if Canvas.TextWidth(Caption) > Width then begin
txtWid := Canvas.TextWidth(Caption);
if txtWid mod Width = 0 then Addon := 0
else Addon := 1;
Height := 16 * ((txtWid div Width) + Addon);
end else
Height := 21;
YInc := Height + 3;
end;
EventRec^.fUnit := TEdit.Create(Form17.ScrollBox1);
with EventRec^.fUnit do begin
Parent := Form17.ScrollBox1;
Name := 'txtUnit' + IntToStr(i);
Text := RealToStr(StrToReal(Fields[1].Value), 2);
Left := XPos[1];
Top := YPos;
Width := XWid[1];
Height := 21;
ReadOnly := True;
end;
EventRec^.fQty := TSpinEdit.Create(Form17.ScrollBox1);
with EventRec^.fQty do begin
Name := 'spnQty' + IntToStr(i);
Min := 0;
Max := 4;
Value := 0;
Left := XPos[2];
Top := YPos;
Width := XWid[2];
Height := 21;
OnClick := Dummy.SpinEditChange;
end;
EventRec^.fValue := TEdit.Create(Form17.ScrollBox1);
with EventRec^.fValue do begin
Parent := Form17.ScrollBox1;
Name := 'txtValue' + IntToStr(i);
Text := '0.00';
Top := YPos;
Left := XPos[3];
Width := XWid[3];
Height := 21;
ReadOnly := True;
end;
EvtObjList.Add(EventRec);
YPos := YPos + YInc;