Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > Delphi: Общие вопросы > TcxExtLookupComboBox с дополнительными кнопками


Автор: lotax 25.11.2009, 15:32
Приветствую...

Использую компонент TcxExtLookupComboBox, потребовалось добавить еще одну
в свойстве компонента данный раздел не обнаружил
добавил следующим образом

Код

procedure TForm1.FormCreate(Sender: TObject);
begin
  cxExtLookupComboBox1.Properties.Buttons.Add.Kind := bkEllipsis;
end;


вопрос как описать событие при нажатие кнопки
так как событие по кнопкам отсутствует...

например в компоненте TcxButtonEdit это событие:
Код

procedure TForm1.cxExtLookupComboBox1PropertiesButtonClick(Sender: TObject;
  AButtonIndex: Integer);

Автор: lotax 26.11.2009, 08:13
Это делается так  smile 
Код

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; 

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)