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 47 48 49 50 51 52 53 54
|
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
StringGrid1->Cells[3][0] = "Nom";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::StringGrid1Click(TObject *Sender)
{
if( StringGrid1->Col == 3 )
{
String d = StringGrid1->Cells[StringGrid1->Col][StringGrid1->Row];
for(int a = 0; a < ComboBox1->Items->Count; a++)
{
if(d == ComboBox1->Items->Strings[a])
{
ComboBox1->ItemIndex = a;
StringGrid1->Cells[StringGrid1->Col][StringGrid1->Row] = ComboBox1->Items->Strings[a];
}
}
TRect Recto = StringGrid1->CellRect(StringGrid1->Col, StringGrid1->Row);
ComboBox1->Top = StringGrid1->Top;
ComboBox1->Left = StringGrid1->Left;
ComboBox1->Top = ComboBox1->Top + Recto.Top + StringGrid1->GridLineWidth;
ComboBox1->Left = ComboBox1->Left + Recto.Left + StringGrid1->GridLineWidth + 1;
ComboBox1->Height = (Recto.Bottom - Recto.Top) + 1;
ComboBox1->Width = Recto.Right - Recto.Left;
ComboBox1->Visible = True;
}
else
{
ComboBox1->Visible = False;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ComboBox1Click(TObject *Sender)
{
StringGrid1->Cells[StringGrid1->Col][StringGrid1->Row] =
ComboBox1->Items->Strings[ComboBox1->ItemIndex];
}
//--------------------------------------------------------------------------- |
Partager