Ignore:
Timestamp:
Mar 22, 2018, 7:59:13 PM (6 years ago)
Author:
chronos
Message:
  • Added: Support for item references.
  • Added: Data and Time value types.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormRecord.pas

    r8 r14  
    8787  NewControl: TControl;
    8888  CellRect: TRect;
     89const
     90  LabelWidth = 300;
    8991begin
    9092  Row := DataRecord;
     
    9294  Labels.Clear;
    9395  for I := 0 to Table.Fields.Count - 1 do begin
    94     CellRect := Rect(10, 10 + I * 70, Panel1.Width - 20, (I + 1) * 70);
     96    CellRect := Rect(10, 10 + I * 35, Panel1.Width - 20, (I + 1) * 35);
    9597    NewLabel := TLabel.Create(Panel1);
    9698    NewLabel.Caption := TField(Table.Fields[I]).TextBefore;
     
    103105      ftString: begin
    104106        NewControl := TEdit.Create(Panel1);
    105         NewControl.Parent := Panel1;
    106         NewControl.Left := CellRect.Left;
    107         NewControl.Top := CellRect.Top + NewLabel.Height + 6;
    108         NewControl.Width := CellRect.Right - CellRect.Left;
     107        NewControl.Anchors := [akLeft, akTop, akRight];
     108        NewControl.Parent := Panel1;
     109        NewControl.Left := CellRect.Left + LabelWidth;
     110        NewControl.Top := CellRect.Top;
     111        NewControl.Width := CellRect.Right - CellRect.Left - LabelWidth;
    109112        NewControl.Visible := True;
    110113        TEdit(NewControl).Text := TValueString(Row.Values[I]).Value;
     
    114117        NewControl := TSpinEdit.Create(Panel1);
    115118        NewControl.Parent := Panel1;
    116         NewControl.Left := CellRect.Left;
    117         NewControl.Top := CellRect.Top + NewLabel.Height + 6;
    118         NewControl.Width := CellRect.Right - CellRect.Left;
     119        NewControl.Left := CellRect.Left + LabelWidth;
     120        NewControl.Top := CellRect.Top;
     121        NewControl.Width := CellRect.Right - CellRect.Left - LabelWidth;
    119122        NewControl.Visible := True;
    120123        TSpinEdit(NewControl).Value := TValueInteger(Row.Values[I]).Value;
     
    124127        NewControl := TDateEdit.Create(Panel1);
    125128        NewControl.Parent := Panel1;
    126         NewControl.Left := CellRect.Left;
    127         NewControl.Top := CellRect.Top + NewLabel.Height + 6;
    128         NewControl.Width := CellRect.Right - CellRect.Left;
     129        NewControl.Left := CellRect.Left + LabelWidth;
     130        NewControl.Top := CellRect.Top;
     131        NewControl.Width := CellRect.Right - CellRect.Left - LabelWidth;
    129132        NewControl.Visible := True;
    130133        TDateEdit(NewControl).Date := TValueDateTime(Row.Values[I]).Value;
     
    134137        NewControl := TCheckBox.Create(Panel1);
    135138        NewControl.Parent := Panel1;
    136         NewControl.Left := CellRect.Left;
    137         NewControl.Top := CellRect.Top + NewLabel.Height + 6;
    138         NewControl.Width := CellRect.Right - CellRect.Left;
     139        NewControl.Left := CellRect.Left + LabelWidth;
     140        NewControl.Top := CellRect.Top;
     141        NewControl.Width := CellRect.Right - CellRect.Left - LabelWidth;
    139142        NewControl.Visible := True;
    140143        TCheckBox(NewControl).Checked := TValueBoolean(Row.Values[I]).Value;
     
    144147        NewControl := TFloatSpinEdit.Create(Panel1);
    145148        NewControl.Parent := Panel1;
    146         NewControl.Left := CellRect.Left;
    147         NewControl.Top := CellRect.Top + NewLabel.Height + 6;
    148         NewControl.Width := CellRect.Right - CellRect.Left;
     149        NewControl.Left := CellRect.Left + LabelWidth;
     150        NewControl.Top := CellRect.Top;
     151        NewControl.Width := CellRect.Right - CellRect.Left - LabelWidth;
    149152        NewControl.Visible := True;
    150153        TFloatSpinEdit(NewControl).Value := TValueFloat(Row.Values[I]).Value;
     154        Controls.Add(NewControl);
     155      end;
     156      ftImage: begin
     157        NewControl := TImage.Create(Panel1);
     158        NewControl.Parent := Panel1;
     159        NewControl.Left := CellRect.Left + LabelWidth;
     160        NewControl.Top := CellRect.Top;
     161        NewControl.Width := CellRect.Right - CellRect.Left - LabelWidth;
     162        NewControl.Height := NewLabel.Height;
     163        NewControl.Visible := True;
     164        //TImage(NewControl).Value := TValueFloat(Row.Values[I]).Value;
     165        Controls.Add(NewControl);
     166      end;
     167      ftReference: begin
     168        NewControl := TComboBox.Create(Panel1);
     169        NewControl.Parent := Panel1;
     170        NewControl.Left := CellRect.Left + LabelWidth;
     171        NewControl.Top := CellRect.Top;
     172        NewControl.Width := CellRect.Right - CellRect.Left - LabelWidth;
     173        NewControl.Height := NewLabel.Height;
     174        NewControl.Visible := True;
     175
     176        TComboBox(NewControl).Items.Add(IntToStr(TValueReference(Row.Values[I]).Value));
    151177        Controls.Add(NewControl);
    152178      end;
     
    166192      ftBoolean: TValueBoolean(Row.Values[I]).Value := TCheckBox(Controls[I]).Checked;
    167193      ftFloat: TValueFloat(Row.Values[I]).Value := TFloatSpinEdit(Controls[I]).Value;
     194      //ftImage: TValueFloat(Row.Values[I]).Value := TFloatSpinEdit(Controls[I]).Value;
    168195    end;
    169196  end;
Note: See TracChangeset for help on using the changeset viewer.