Это делается так
| Код | type TcxPopupEditPropertiesAccess = class(TcxPopupEditProperties); TcxCustomEditPropertiesAccess = class(TcxCustomEditProperties); TcxLookupComboBoxPropertiesAccess = class(TcxLookupComboBoxProperties); procedure TForm1.AddButton(Control: TObject; OnButtonClick: TcxEditButtonClickEvent; TypeId: integer = 1); var PopupEditProp: TcxPopupEditPropertiesAccess; LookupComboBoxProp: TcxLookupComboBoxPropertiesAccess; Prop: TcxCustomEditPropertiesAccess; Btn: TcxEditButton; begin if Control is TcxGridDBColumn then Prop := TcxCustomEditPropertiesAccess(TcxGridDBColumn(Control).Properties); if Control is TcxPopupEdit then Prop := TcxCustomEditPropertiesAccess(TcxPopupEdit(Control).Properties); if Control is TcxDBLookupComboBox then Prop := TcxCustomEditPropertiesAccess(TcxDBLookupComboBox(Control).Properties); Btn := Prop.Buttons.Add as TcxEditButton; case TypeId of 1: Btn.Kind := bkEllipsis; 2: begin Btn.Kind := bkGlyph; // Btn.Glyph.Assign(Bitmap); end; end; Prop.OnButtonClick := OnButtonClick; end; function TForm1.GetButton(Control: TObject; Index: integer): TcxEditButton; var Prop: TcxCustomEditPropertiesAccess; Btn: TcxEditButton; begin if Control is TcxGridDBColumn then Prop :=TcxCustomEditPropertiesAccess(TcxGridDBColumn(Control).Properties); if Control is TcxPopupEdit then Prop := TcxCustomEditPropertiesAccess(TcxPopupEdit(Control).Properties); if Control is TcxDBLookupComboBox then Prop := TcxCustomEditPropertiesAccess(TcxDBLookupComboBox(Control).Properties); if Prop.Buttons.Count > Index then result := Prop.Buttons[Index] else result := nil; end; procedure TForm1.Button2Click(Sender: TObject); begin AddButton(cxPopupEdit1, cxButtonEdit1PropertiesButtonClick); end; procedure TForm1.Button3Click(Sender: TObject); begin GetButton(cxPopupEdit1, 0).Visible := false; end; procedure TForm1.cxButtonEdit1PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); begin ShowMessage(inttostr(AButtonIndex)); end;
|
|