想要的效果如下:
点击combobox的下拉箭头时,出现一系列的数据,用鼠标移动到某一条数据上时(还没有点选),单击鼠标右键的“删除”选项将对应的数据删除!

解决方案 »

  1.   

    下面的代码只是近似地实现了楼主的要求(说近似,是因为:要是使用弹出菜单,选择“删除?”后才删除,则Combobox的下拉框会因失去焦点而消失;要是不使用弹出菜单,右击就直接删除,则可以)type
      TForm1 = class(TForm)
        ComboBox1: TComboBox;
        PopupMenu1: TPopupMenu;
        N1: TMenuItem;
        procedure OnMouseRBtnDown(var Msg : TMsg; var Handled : Boolean);
        procedure FormCreate(Sender: TObject);
        procedure N1Click(Sender: TObject);//弹出菜单的“删除?”项
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.OnMouseRBtnDown(var Msg : TMsg; var Handled : Boolean);
    begin
      if Msg.message = WM_rButtonDown then
         begin
         PopUpMenu1.Popup(Mouse.CursorPos.X,Mouse.CursorPos.Y);
         //如果希望右击直接删除(不用弹出菜单),则把N1Click的代码放在这里,把上行删掉
         end;
    end;procedure TForm1.FormCreate(Sender: TObject);
    begin
      Application.OnMessage:=OnMouseRBtnDown;
    end;procedure TForm1.N1Click(Sender: TObject);
    var
      Index : Integer;
    begin
      Index := Combobox1.ItemIndex;
      Combobox1.Items.Delete(Index);
      Combobox1.ItemIndex := Index;
      Combobox1.Perform(CB_ShowDropDown,LongInt(True),0);
    end;
      

  2.   

    其实楼主还可以用Edit和ListBox等控件模拟一个这样的Combobox的
      

  3.   

    楼上说的对!~来晚了记住要把combobox里面的PopupMenu属性设置成PopupMenu1