Changeset 4 for trunk/Forms/UFormFields.pas
- Timestamp:
- Jan 18, 2015, 11:29:26 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormFields.pas
r3 r4 15 15 TFormFields = class(TForm) 16 16 AAdd: TAction; 17 AOk: TAction; 18 ACancel: TAction; 17 19 ActionList1: TActionList; 18 20 AModify: TAction; … … 27 29 ToolButton2: TToolButton; 28 30 ToolButton3: TToolButton; 31 ToolButton4: TToolButton; 32 ToolButton5: TToolButton; 29 33 procedure AAddExecute(Sender: TObject); 34 procedure ACancelExecute(Sender: TObject); 30 35 procedure AModifyExecute(Sender: TObject); 36 procedure AOkExecute(Sender: TObject); 31 37 procedure ARemoveExecute(Sender: TObject); 32 38 procedure FormShow(Sender: TObject); … … 37 43 { private declarations } 38 44 public 39 Table: TTable; 45 Fields: TFields; 46 TableName: string; 40 47 procedure UpdateInterface; 41 48 procedure ReloadList; … … 48 55 49 56 uses 50 UFormField ;57 UFormField, UDataTypes; 51 58 52 59 {$R *.lfm} … … 56 63 procedure TFormFields.FormShow(Sender: TObject); 57 64 begin 65 Caption := 'Table fields - ' + TableName; 58 66 UpdateInterface; 59 67 ReloadList; … … 69 77 if FormField.ShowModal = mrOk then begin 70 78 FormField.Save(NewField); 71 Table.Fields.Add(NewField);79 Fields.Add(NewField); 72 80 ReloadList; 73 81 end else NewField.Free; 82 end; 83 84 procedure TFormFields.ACancelExecute(Sender: TObject); 85 begin 86 Close; 74 87 end; 75 88 … … 85 98 end; 86 99 100 procedure TFormFields.AOkExecute(Sender: TObject); 101 begin 102 ModalResult := mrOk; 103 end; 104 87 105 procedure TFormFields.ARemoveExecute(Sender: TObject); 88 106 begin 89 107 if Assigned(ListView1.Selected) then begin 90 Table.Fields.Remove(ListView1.Selected.Data);108 Fields.Remove(ListView1.Selected.Data); 91 109 ReloadList; 92 110 UpdateInterface; … … 96 114 procedure TFormFields.ListView1Data(Sender: TObject; Item: TListItem); 97 115 begin 98 if (Item.Index >= 0) and (Item.Index < Table.Fields.Count) then99 with TField( Table.Fields[Item.Index]) do begin116 if (Item.Index >= 0) and (Item.Index < Fields.Count) then 117 with TField(Fields[Item.Index]) do begin 100 118 Item.Caption := Name; 101 119 Item.SubItems.Add(FieldTypeString[FieldType]); … … 103 121 Item.SubItems.Add(TextBefore); 104 122 Item.SubItems.Add(TextAfter); 105 Item.Data := Table.Fields[Item.Index];123 Item.Data := Fields[Item.Index]; 106 124 end; 107 125 end; … … 121 139 procedure TFormFields.ReloadList; 122 140 begin 123 ListView1.Items.Count := Table.Fields.Count;141 ListView1.Items.Count := Fields.Count; 124 142 ListView1.Repaint; 125 143 end;
Note:
See TracChangeset
for help on using the changeset viewer.