谁能帮我实现StringGrid的某列Cell具有下拉列表的功能。 不要那种使用combobox嵌入的方法,有现成控件也可以。

解决方案 »

  1.   

    我看只能使用combobox嵌入的方法了,除非使用第三方控件封装了的。
      

  2.   

    这是我以前写的
    procedure TFORM1.StringGridMouseDown(Sender: TObject;
      Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    var
      GridCoord: TGridCoord;
      Rect: TRect;
      I: Integer;
    begin
      ComboBoxParamstr.Visible := False;
      GridCoord := StringGrid.MouseCoord(X, Y);
      FRow := GridCoord.Y;
      FCol := GridCoord.X;
      if (FRow <= 0) or (FCol < 0) then exit;
      Rect := StringGrid.CellRect(FCol, FRow + 1);
      ComboBoxParamstr.Text := StringGrid.Cells[FCol,FRow];
      ComboBoxParamstr.Top := Rect.Top - 2;
      ComboBoxParamstr.Left := Rect.Left + 10;
      ComboBoxParamstr.Width := Rect.Right - Rect.Left;
      ComboBoxParamstr.Visible := True;
      case GridCoord.X of
        0://字段
          begin
            ComboBoxParamstr.Items := FlstFields;
          end;
        1://字段类型
          begin
            ComboBoxParamstr.Visible := False;
            //ComboBoxParamstr.Items := FlstFieldTypes;
          end;
        2://排序类型
          begin
            ComboBoxParamstr.Items := FlstOrdType;
          end;
        3://排序顺序
          begin
            ComboBoxParamstr.Clear;
            for I := 1 to FMaxOrdNo do
              ComboBoxParamstr.Items.Add(IntToStr(I));
            ComboBoxParamstr.Text := StringGrid.Cells[FCol,FRow];
          end;
        4://关系
          begin
            ComboBoxParamstr.Items := FlstRelat;
          end;
        5://准则
          begin
            ComboBoxParamstr.Items := FlstRule;
          end;
        6://值
          begin
            ComboBoxParamstr.Items := FlstValue;
          end;
      end;
    end;
      

  3.   

    用Tstrings封装一个属性就可以,很简单
      

  4.   

    已经找到TMS.Component.Pack.Pro.v3.3中的TAdvStringGrid解决问题。还是非常感谢大家的回答。并向大家推荐这个控件,功能非常强,可以在StringGrid中整合combobox、checkbox、spinEdit等等。TMS的控件是获得大奖的,呵呵,我就不多说了,我还没用上手呢。