1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
X = 1;
Y = 1;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::StringGrid1KeyPress(TObject *Sender, char &Key)
{
int i=0;
if(StringGrid1->Cells[X][Y] != "") //si la case n'est pas vide
{
if(Key != 8)
{
for(i=X; i<StringGrid1->ColCount; i++)
{
if(StringGrid1->Cells[i][Y] == "")
{
StringGrid1->Cells[i][Y] = Key;
Key = NULL;
break;
}
}
}
else
{
for(i=StringGrid1->ColCount; i >= 1; i--)
{
if(StringGrid1->Cells[i][Y] != "")
{
StringGrid1->Cells[i][Y] = "";
Key = NULL;
break;
}
}
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::StringGrid1SelectCell(TObject *Sender, int ACol,
int ARow, bool &CanSelect)
{
X = ACol;
Y = ARow;
} |