Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit PartyView;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
- Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, BidirectionalParty,
- Vcl.Grids, Vcl.StdCtrls;
- const
- HEADER_ID = '№';
- HEADER_NAME = 'Название партии';
- HEADER_POSITION = 'Политическая позиция';
- type
- TPartyViewFrame = class(TFrame)
- GroupBox1: TGroupBox;
- SG: TStringGrid;
- procedure FrameEnter(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- Constructor Create(aOwner : TComponent); override;
- end;
- implementation
- {$R *.dfm}
- uses Main;
- Constructor TPartyViewFrame.Create(aOwner: TComponent);
- begin
- inherited Create(aOwner);
- end;
- procedure ClearStringGrid(SG : TStringGrid);
- var
- I, J : Integer;
- begin
- for I := 0 to SG.RowCount - 1 do
- begin
- SG.Rows[I].Clear;
- end;
- end;
- procedure FillHeadersSG(SG : TStringGrid);
- begin
- SG.Cells[0,0] := HEADER_ID;
- SG.Cells[1,0] := HEADER_NAME;
- SG.Cells[2,0] := HEADER_POSITION;
- SG.ColWidths[0] := 50;
- SG.ColWidths[1] := 600;
- SG.ColWidths[2] := 600;
- end;
- Procedure FillStringGrid(SG : TStringGrid);
- var
- I, J : Integer;
- TempHead : PPartyList;
- begin
- ClearStringGrid(SG);
- FillHeadersSG(SG);
- TempHead := Main.PartyList.Head;
- I := 1;
- J := 0;
- SG.RowCount := Main.PartyList.Count + 1;
- // Цикл для прохода по списку
- while TempHead <> NIL do
- begin
- with SG do
- begin
- Cells[J, I] := (TempHead^.Party.IdParty + 1).ToString;
- Cells[J + 1, I] := TempHead^.Party.Name;
- Cells[J + 2, I] := TempHead^.Party.PoliticalPosition;
- end;
- Inc(I);
- TempHead := TempHead^.Next; // Переход к следующей записи
- end;
- Dispose(TempHead);
- end;
- procedure TPartyViewFrame.FrameEnter(Sender: TObject);
- begin
- FillStringGrid(SG);
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement