GamerSK

neviem... asi nejaky stringgrid

Jan 14th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.33 KB | None | 0 0
  1. //---------------------------------------------------------------------------
  2.  
  3. #include <vcl.h>
  4. #pragma hdrstop
  5.  
  6. #include "Unit1.h"
  7. //---------------------------------------------------------------------------
  8. #pragma package(smart_init)
  9. #pragma resource "*.dfm"
  10. TForm1 *Form1;
  11. int r = 1;
  12. bool is_player1 = true;
  13. //Stringgrid pomenuj sgudaje . 3 Stlpce a 2 Riadky a z toho jeden fixovany
  14. //Nastav nazov stlpcov: Meno, Priezvisko a Trieda
  15. //---------------------------------------------------------------------------
  16. __fastcall TForm1::TForm1(TComponent* Owner)
  17.     : TForm(Owner)
  18. {
  19. }
  20. //---------------------------------------------------------------------------
  21. void __fastcall TForm1::FormCreate(TObject *Sender)
  22. {
  23.     sgudaje->Cells[0][0]="Meno";
  24.     sgudaje->Cells[1][0]="Priezvisko";
  25.     sgudaje->Cells[2][0]="Trieda";
  26. }
  27. //---------------------------------------------------------------------------
  28. void __fastcall TForm1::sgudajeSelectCell(TObject *Sender, int ACol, int ARow, bool &CanSelect)
  29.  
  30. {
  31.     if (sgudaje->Cells[ACol][ARow] != "") {
  32.         sgudaje->Cells[ACol][ARow]=InputBox("Zmena udajov v bunke","Udaj",sgudaje->Cells[ACol][ARow]);
  33.     }
  34. }
  35. //---------------------------------------------------------------------------
  36. void __fastcall TForm1::Button1Click(TObject *Sender)
  37. {
  38.     if ( edtMeno->Text != "" || edtPriezvisko->Text != "" || edtTrieda->Text != "" ) {
  39.         sgudaje->Cells[0][r]=edtMeno->Text;
  40.         sgudaje->Cells[1][r]=edtPriezvisko->Text;
  41.         sgudaje->Cells[2][r]=edtTrieda->Text;
  42.         edtMeno->Text = "";
  43.         edtPriezvisko->Text = "";
  44.         edtTrieda->Text = "";
  45.         r++;
  46.         sgudaje->RowCount++;
  47.     }
  48. }
  49. //---------------------------------------------------------------------------
  50. void __fastcall TForm1::Button2Click(TObject *Sender)
  51. {
  52.     for (int r = 1; r < sgudaje->RowCount-1; r++) {
  53.         ListBox1->Items->Add(sgudaje->Cells[0][r]);
  54.     }
  55. }
  56. //---------------------------------------------------------------------------
  57. void __fastcall TForm1::StringGrid1SelectCell(TObject *Sender, int ACol, int ARow,
  58.           bool &CanSelect)
  59. {
  60.     if ( StringGrid1->Cells[ACol][ARow] == "" ) {
  61.         if ( is_player1 ) {
  62.             StringGrid1->Cells[ACol][ARow]="X";
  63.             is_player1 = false;
  64.         } else {
  65.            StringGrid1->Cells[ACol][ARow]="O";
  66.            is_player1 = true;
  67.         }
  68.     }
  69. }
  70. //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment