Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "Unit1.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TForm1 *Form1;
- int r = 1;
- bool is_player1 = true;
- //Stringgrid pomenuj sgudaje . 3 Stlpce a 2 Riadky a z toho jeden fixovany
- //Nastav nazov stlpcov: Meno, Priezvisko a Trieda
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::FormCreate(TObject *Sender)
- {
- sgudaje->Cells[0][0]="Meno";
- sgudaje->Cells[1][0]="Priezvisko";
- sgudaje->Cells[2][0]="Trieda";
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::sgudajeSelectCell(TObject *Sender, int ACol, int ARow, bool &CanSelect)
- {
- if (sgudaje->Cells[ACol][ARow] != "") {
- sgudaje->Cells[ACol][ARow]=InputBox("Zmena udajov v bunke","Udaj",sgudaje->Cells[ACol][ARow]);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button1Click(TObject *Sender)
- {
- if ( edtMeno->Text != "" || edtPriezvisko->Text != "" || edtTrieda->Text != "" ) {
- sgudaje->Cells[0][r]=edtMeno->Text;
- sgudaje->Cells[1][r]=edtPriezvisko->Text;
- sgudaje->Cells[2][r]=edtTrieda->Text;
- edtMeno->Text = "";
- edtPriezvisko->Text = "";
- edtTrieda->Text = "";
- r++;
- sgudaje->RowCount++;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button2Click(TObject *Sender)
- {
- for (int r = 1; r < sgudaje->RowCount-1; r++) {
- ListBox1->Items->Add(sgudaje->Cells[0][r]);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::StringGrid1SelectCell(TObject *Sender, int ACol, int ARow,
- bool &CanSelect)
- {
- if ( StringGrid1->Cells[ACol][ARow] == "" ) {
- if ( is_player1 ) {
- StringGrid1->Cells[ACol][ARow]="X";
- is_player1 = false;
- } else {
- StringGrid1->Cells[ACol][ARow]="O";
- is_player1 = true;
- }
- }
- }
- //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment