Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Pre viac otázok mi píšte :)
- //Celá zložka pre Lazarus (trošku sa buguje procedúra OnSelectCell :( ) https://mega.nz/#F!fBdUGZIa!2Zz9_KKu4zmyTPpBLKMikw
- unit Unit1;
- {$mode objfpc}{$H+}
- interface
- uses
- Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Grids,
- StdCtrls, Spin;
- type
- { TForm1 }
- TForm1 = class(TForm)
- Button1: TButton;
- Button2: TButton;
- Label1: TLabel;
- Label2: TLabel;
- SpinEdit1: TSpinEdit;
- SpinEdit2: TSpinEdit;
- StringGrid1: TStringGrid;
- StringGrid2: TStringGrid;
- procedure Button1Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure StringGrid1SelectCell(Sender: TObject; aCol, aRow: Integer;
- var CanSelect: Boolean);
- procedure StringGrid2SelectCell(Sender: TObject; aCol, aRow: Integer;
- var CanSelect: Boolean);
- private
- public
- end;
- var
- Form1: TForm1;
- riadok:word; //Definícia počítadla riadkov
- x:boolean; //Definícia X/O
- implementation
- {$R *.lfm}
- { TForm1 }
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- //FOR DELPHI NOOBS
- StringGrid1.Cells[0,0]:='1. Číslo'; //Pridá hore daný string
- StringGrid1.Cells[1,0]:='2. Číslo'; //Pridá hore daný string
- StringGrid1.Cells[2,0]:='Výsledok'; //Pridá hore daný string
- riadok:=1; //"Vynulovanie" počítadla
- x:=true; //Nastavenie pre prve X
- end;
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- StringGrid1.Cells[0,riadok]:=inttostr(SpinEdit1.Value); //Pridá do daného riadka a prvého stĺpca VALUE z spinEditu1
- StringGrid1.Cells[1,riadok]:=inttostr(SpinEdit2.Value); //Pridá do daného riadka a druhého stĺpca VALUE z spinEditu2
- StringGrid1.Cells[2,riadok]:=inttostr(SpinEdit1.Value+SpinEdit2.Value); //Spočíta spinEdit1 a spinEdit2 a pridá ich do tretieho stĺpca
- SpinEdit1.Value:=0; SpinEdit2.Value:=0; //Vynulovanie spinEditov1 a 2
- StringGrid1.RowCount:=StringGrid1.RowCount+1; //Pridanie dalšieho riadka
- inc(riadok); //Zväčšenie čísla pre riadok
- end;
- procedure TForm1.StringGrid1SelectCell(Sender: TObject; aCol, aRow: Integer;
- var CanSelect: Boolean);
- begin
- StringGrid1.Cells[aCol,aRow]:=inputbox('Zmena údajov','Zadajte nový údaj',StringGrid1.Cells[aCol,aRow]); //Editácia po označení
- end;
- procedure TForm1.Button2Click(Sender: TObject); //Vynulovanie pola pre piškvorky
- var i,j:byte;
- begin
- for i:=0 to 2 do
- begin
- for j:=0 to 2 do
- begin
- StringGrid2.Cells[i,j]:='';
- end;
- end;
- i:=0; j:=0;
- end;
- procedure TForm1.StringGrid2SelectCell(Sender: TObject; aCol, aRow: Integer; //Logika piškvoriek (jednoduchá xd)
- var CanSelect: Boolean);
- begin
- if X then
- begin
- if StringGrid2.Cells[aCol,aRow] = '' then
- begin
- StringGrid2.Cells[aCol,aRow]:='X';
- x:=false;
- end;
- end
- else
- begin
- if StringGrid2.Cells[aCol,aRow] = '' then
- begin
- StringGrid2.Cells[aCol,aRow]:='O';
- x:=true;
- end;
- end;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment