请问如何在STRINGGRID中加入其它控件(例如检查框,下拉列表框等)

2025-02-02 16:57:04
推荐回答(4个)
回答1:

procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);begin if gdSelected in State then begin CheckBox1.SetBounds(Rect.Left + StringGrid1.Left + 2, Rect.Top + StringGrid1.Top + 2, StringGrid1.ColWidths[ACol], StringGrid1.RowHeights[ARow]); end;end;

回答2:

TStringGrid本身就有编辑框,它从TCustomGrid派生而来,你看一下VCL源代码,就知道了。 另外TDBGrid也是一种Grid控件,甚至可以显示对话框。

回答3:

可以用API实现。

回答4:

补充一下,下拉框也有。可能还有一个事件来让你改写。