Bonjour à tous,
Je cherche à intégrer, dans certaines colonnes d'un tStringGrid, un Combobox me donnant un accès à une liste d'objets par leur nom.
Le test ci-dessous fonctionne parfaitement tant que je récupère le String.
Est-il possible de récupérer, dans la cellule du StringGrid, l'objet qui est associé à au champ de la StringList, plutôt que la chaine elle-même ?
avec :
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 // Gestion StringList TGetEditStyleEvent = procedure(TSender: TObject; ACol, ARow: Integer; var EditStyle: TEditStyle) of object; TStringGrid = Class(Grids.TStringGrid) Private FDropdownRowCount: Integer; FOnEditButtonClick: TNotifyEvent; FOnGetEditStyle: TGetEditStyleEvent; FOnGetPickListItems: TOnGetPickListItems; procedure SetDropDownRowCount(value: Integer); // procedure SetOnEditButtonClick(value: TNotifyEvent); procedure SetOnGetPicklistItems(value: TOnGetPickListItems); protected function CreateEditor: TInplaceEdit; override; function GetEditStyle(ACol, ARow: Integer): TEditStyle; override; public constructor Create(AOwner: TComponent); override; published property DropdownRowCount: Integer read FDropdownRowCount write SetDropDownRowCount default cNbCtrlMax; // property OnEditButtonClick: TNotifyEvent read FOnEditButtonClick // write SetOnEditButtonClick; property OnGetEditStyle: TGetEditStyleEvent read FOnGetEditStyle write FOnGetEditStyle; property OnGetPickListItems: TOnGetPickListItems read FOnGetPickListItems write SetOnGetPicklistItems; end;
Merci pour votre aide,
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79 Constructor TStringGrid.Create; begin inherited Create(AOwner); FDropdownRowCount := 2; end; function TStringGrid.CreateEditor: TInplaceEdit; begin result := TInplaceEditList.Create(self); with TInplaceEditList(result) do begin RowCount := FDropdownRowCount; OnGetPickListItems := FOnGetPickListItems; OnEditButtonClick := FOnEditButtonClick; end; end; function TStringGrid.GetEditStyle(ACol, ARow: Integer): TEditStyle; begin result := esSimple; if Assigned(FOnGetEditStyle) then FOnGetEditStyle(self, ACol, ARow, result); Invalidate; end; procedure TStringGrid.SetDropDownRowCount(value: Integer); begin FDropdownRowCount := value; if Assigned(InplaceEditor) then TInplaceEditList(InplaceEditor).DropdownRows := value; Invalidate; end; // procedure TStringGrid.SetOnEditButtonClick(value: TNotifyEvent); // begin // FOnEditButtonClick := value; // if Assigned(InplaceEditor) then // TInplaceEditList(InplaceEditor).OnEditButtonClick := value; // Invalidate; // end; procedure TStringGrid.SetOnGetPicklistItems(value: TOnGetPickListItems); begin FOnGetPickListItems := value; if Assigned(InplaceEditor) then TInplaceEditList(InplaceEditor).OnGetPickListItems := value; Invalidate; end; procedure TfrmDynFct.OnGetEditStyle(TSender: TObject; ACol, ARow: Integer; var EditStyle: TEditStyle); begin case ACol of cColRefObjectName: EditStyle := esPickList; cColOperateur: EditStyle := esPickList; cColRefValue: EditStyle := esSimple; cColFctNext: EditStyle := esPickList; end; end; procedure TfrmDynFct.OnGetPickListItems(ACol, ARow: Integer; Items: TStrings); begin case ACol of cColRefObjectName: Items.Assign(RefVisuelListe); cColOperateur: Items.Assign(RefOperateurListe); // cColRefValue: // cColDelay: cColFctNext: Items.Assign(RefLogiqueListe); end; end;
Partager