unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Grids;
type
TForm1 =
class(TForm)
StringGrid1: TStringGrid;
ComboBox1: TComboBox;
procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
procedure FormCreate(Sender: TObject);
procedure StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer;
var CanSelect: Boolean);
private
{ Private-Deklarationen }
procedure SetRect(Rect:TRect);
public
{ Public-Deklarationen }
end;
var
aktCellX,aktCellY : integer;
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.SetRect(Rect:TRect);
var r:TRect;
begin
CopyRect(r,rect);
r.BottomRight := combobox1.Parent.ScreenToClient(StringGrid1.ClientToScreen(r.BottomRight));
r.TopLeft := combobox1.Parent.ScreenToClient(StringGrid1.ClientToScreen(r.TopLeft));
ComboBox1.SetBounds(r.left,r.top,r.right-r.left,r.bottom-r.top);
ComboBox1.BringToFront;
end;
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
if (AktCellX = StringGrid1.ColCount-1)
then
begin
setRect(Stringgrid1.CellRect(AktCellX,AktCellY));
ComboBox1.Visible := true;
end
else
ComboBox1.Visible := false;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
ComboBox1.parent := StringGrid1;
end;
procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol,
ARow: Integer;
var CanSelect: Boolean);
begin
aktCellX := ACol;
aktCellY := ARow;
end;
end.