Suite a ce post
et a ce lien
Voici le code complete pour gerer un CheckListBox dans une cellule d'un StringGrid
Sur la Form un StringGrid un CheckListBox les Items completes et Visible a false
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
55
56
57
58
59
60
61
62 //--------------------------------------------------------------------------- #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[6][0] = "Nom"; } //--------------------------------------------------------------------------- void __fastcall TForm1::StringGrid1Click(TObject *Sender) { int a; if( StringGrid1->Col == 6 ) { String d = StringGrid1->Cells[StringGrid1->Col][StringGrid1->Row]; for(a = 0; a < CheckListBox1->Items->Count; a++) { CheckListBox1->Checked[a] = 0; if(d == CheckListBox1->Items->Strings[a]) { CheckListBox1->ItemIndex = a; CheckListBox1->Checked[a] = 1; if(d == "") { CheckListBox1->Checked[a] = 0; } CheckListBox1->ItemEnabled[a]; StringGrid1->Cells[StringGrid1->Col][StringGrid1->Row] = CheckListBox1->Items->Strings[a]; } } TRect Recto = StringGrid1->CellRect(StringGrid1->Col, StringGrid1->Row); CheckListBox1->Top = StringGrid1->Top; CheckListBox1->Left = StringGrid1->Left; CheckListBox1->Top = CheckListBox1->Top + Recto.Top + StringGrid1->GridLineWidth; CheckListBox1->Left = CheckListBox1->Left + Recto.Left + StringGrid1->GridLineWidth + 1; CheckListBox1->Height = (Recto.Bottom - Recto.Top) + 1; CheckListBox1->Width = Recto.Right - Recto.Left; CheckListBox1->Visible = True; CheckListBox1->BringToFront(); } else { CheckListBox1->Visible = false; } } //--------------------------------------------------------------------------- void __fastcall TForm1::CheckListBox1ClickCheck(TObject *Sender) { StringGrid1->Cells[StringGrid1->Col][StringGrid1->Row] = CheckListBox1->Items->Strings[CheckListBox1->ItemIndex]; } //---------------------------------------------------------------------------
Partager