http://www.e-jun.com/bbs/Announce/Announce.asp?BoardID=1&ID=5
做得和Excel难分真假,理论上单元格中可放任何控件,只要在事件里写点代码就行了
procedure TForm1.ZJGrid1GetCellEditor(Sender: TObject; ACoord: TPoint;
var AControl: TWinControl);
begin
// 第二列的编辑器采用ComboBox
if ACoord.X = 2 then AControl := ComboBox1;
end;
procedure TForm1.ZJGrid1EditorLoadCell(Sender: TObject; ACoord: TPoint;
AControl: TWinControl);
begin
// 当单元格进入编辑状态时首先要给ComboBox赋初值
if ACoord.X = 2 then ComboBox1.Text := ZJGrid1.Items[ACoord].Text;
end;
procedure TForm1.ZJGrid1EditorSaveCell(Sender: TObject; ACoord: TPoint;
AControl: TWinControl);
begin
if ACoord.X = 2 then ZJGrid1.Items[ACoord].Text := ComboBox1.Text;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
ZJGrid1.CellClass.Cols[2] := TZjComboCell;
ZjGrid1.CellClass.Cols[3] := TZjCheckBoxCell;
end;