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了!
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了!