Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamically Creating a TSpinEdit component

Status
Not open for further replies.

Streetie

Programmer
Jul 22, 2005
1
GB
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;
 
It often takes another pair of eyes to spot an omission/error that's been staring you in the face for hours!

Clive [infinity]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer."
Paul Ehrlich
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top