初始化combobox1的visible为falseprocedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); begin if gdfocused in state then begin if column.FieldName='Zh' then//你要让combobox显示的那列的字段名 begin form1.ComboBox1.Left:=rect.Left+form1.DBGrid1.Left; form1.ComboBox1.Top:=rect.Top+form1.DBGrid1.Top; form1.ComboBox1.Width:=rect.Right-rect.Left; form1.ComboBox1.Height:=rect.Bottom-rect.Top; form1.ComboBox1.Visible:=true; end; end; end;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if gdfocused in state then
begin
if column.FieldName='Zh' then//你要让combobox显示的那列的字段名
begin
form1.ComboBox1.Left:=rect.Left+form1.DBGrid1.Left;
form1.ComboBox1.Top:=rect.Top+form1.DBGrid1.Top;
form1.ComboBox1.Width:=rect.Right-rect.Left;
form1.ComboBox1.Height:=rect.Bottom-rect.Top;
form1.ComboBox1.Visible:=true;
end;
end;
end;