GamerSK

some grid

Dec 20th, 2018
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.77 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 i = 0;
  12. //---------------------------------------------------------------------------
  13. __fastcall TForm1::TForm1(TComponent* Owner)
  14.     : TForm(Owner)
  15. {
  16. }
  17. //---------------------------------------------------------------------------
  18. void __fastcall TForm1::FormCreate(TObject *Sender)
  19. {
  20.     StringGrid1->Cells[0][0]="Meno";
  21.     StringGrid1->Cells[1][0]="Priezvisko";
  22.     StringGrid1->Cells[2][0]="Trieda";
  23.     StringGrid1->Cells[3][0]="Dátum narodenia";
  24.     StringGrid1->Cells[4][0]="Číslo";
  25. }
  26. //---------------------------------------------------------------------------
  27. void __fastcall TForm1::Button1Click(TObject *Sender)
  28. {
  29.     if ( edtF->Text != "" && edtL->Text != "" && edtC->Text != "" && sedtD->Value != 0 && sedtM->Value != 0 && sedtY->Value != 0 ) {
  30.         i++;
  31.         StringGrid1->Cells[0][i]=edtF->Text;
  32.         StringGrid1->Cells[1][i]=edtL->Text;
  33.         StringGrid1->Cells[2][i]=edtC->Text;
  34.         StringGrid1->Cells[3][i]=IntToStr(sedtD->Value)+"."+IntToStr(sedtM->Value)+"."+IntToStr(sedtY->Value);
  35.         StringGrid1->Cells[4][i]=IntToStr(random(100));
  36.         StringGrid1->RowCount++;
  37.         edtF->Text = "";
  38.         edtL->Text = "";
  39.         edtC->Text = "";
  40.         sedtD->Value = 0;
  41.         sedtM->Value = 0;
  42.         sedtY->Value = 0;
  43.         edtF->SetFocus();
  44.     } else ShowMessage("Vyplnte vsetky polia !!!!!");
  45. }
  46. //---------------------------------------------------------------------------
  47. void __fastcall TForm1::StringGrid1SelectCell(TObject *Sender, int ACol, int ARow,
  48.           bool &CanSelect)
  49. {
  50.     if ( StringGrid1->Cells[ACol][ARow] != "" ) {
  51.         StringGrid1->Cells[ACol][ARow] = InputBox("Zmena udajov v tabulke","Data",StringGrid1->Cells[ACol][ARow]);
  52.     } else ShowMessage("Nemôžete upravovať tabuľku ak tam nič nieje :)");
  53. }
  54. //---------------------------------------------------------------------------
  55. void __fastcall TForm1::Button2Click(TObject *Sender)
  56. {
  57.     for (i = 1; i < StringGrid1->RowCount-1; i++) {
  58.         ListBox1->Items->Add(StringGrid1->Cells[0][i]);
  59.     }
  60. }
  61. //---------------------------------------------------------------------------
  62. void __fastcall TForm1::Button3Click(TObject *Sender)
  63. {
  64.     StringGrid2->RowCount = StringGrid1->RowCount;
  65.     for (i = 0; i < StringGrid1->RowCount-1; i++) {
  66.         StringGrid2->Cells[0][i]=StringGrid1->Cells[0][i];
  67.         StringGrid2->Cells[1][i]=StringGrid1->Cells[1][i];
  68.         StringGrid2->Cells[2][i]=StringGrid1->Cells[2][i];
  69.         StringGrid2->Cells[3][i]=StringGrid1->Cells[3][i];
  70.         StringGrid2->Cells[4][i]=StringGrid1->Cells[4][i];
  71.     }
  72. }
  73. //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment