我想在完成这样一个功能:
用鼠标点击STRINGGRID某一单元格时,在单元格显示一个COMBOBOX,
但是COMBOBOX可以在STRINGGRID显示,下拉条无法显示,是什么原因?有什么办法可以解决?

解决方案 »

  1.   

    你的COMBOBOX可能在STRINGGRID的单元格里,所以看不到。我用COMBOBOX在STRINGGRID里跟随鼠标,如果到了要显示的位置,单击就可以看到COMBOBOX
      

  2.   

    procedure Tfrm1.sgDrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
    begin
      inherited;
      if (gdFocused in State) then
      begin
        with sg do
        begin
          if (Cells[Acol,0] = 'A') or (Cells[Acol, 0] = 'B') then
          begin
            COMBOBOX.Left := Rect.Left + Left;
            COMBOBOX.Top := Rect.Top + Top + 3;
            COMBOBOX.Width := Rect.Right - Rect.Left + 2;
            COMBOBOX.Visible := true;
            COMBOBOX.Items.Clear;
            COMBOBOX.SetFocus;
            COMBOBOX.Text := Cells[Col, Row];
          end
          else
            COMBOBOX.Visible := False;
      end;
    在onDropDown事件里写COMBOBOX.items.add()你想要的就OK了!