dblookupcombobox inside a dbgrid

From: AB (AB_at_xyz.com)
Date: 08/27/04


Date: Fri, 27 Aug 2004 17:03:53 GMT

Hello together,

I have a drop down list like in the site

http://delphi.about.com/library/weekly/aa101403b.htm

procedure TForm1.DBGrid1DrawColumnCell
  (Sender: TObject;
   const Rect: TRect;
   DataCol: Integer;
   Column: TColumn;
   State: TGridDrawState);
begin
  if (gdFocused in State) then
  begin
    if (Column.Field.FieldName = DBLookupComboBox1.DataField) then
    with DBLookupComboBox1 do
    begin
      Left := Rect.Left + DBGrid1.Left + 2;
      Top := Rect.Top + DBGrid1.Top + 2;
      Width := Rect.Right - Rect.Left;
      Width := Rect.Right - Rect.Left;
      Height := Rect.Bottom - Rect.Top;

      Visible := True;
    end;
  end
end;

procedure TForm1.DBGrid1ColExit(Sender: TObject);
begin
  if DBGrid1.SelectedField.FieldName = DBLookupComboBox1.DataField then
    DBLookupComboBox1.Visible := False
end;

procedure TForm1.DBGrid1KeyPress(Sender: TObject; var Key: Char);
begin
  if (key = Chr(9)) then Exit;

  if (DBGrid1.SelectedField.FieldName = DBLookupComboBox1.DataField) then
  begin
    DBLookupComboBox1.SetFocus;
    SendMessage(DBLookupComboBox1.Handle, WM_Char, word(Key), 0);
  end
end;

and would like to know if its possible to let the dblookupcombobox disappear
while typing in a new (not an old known one from the selective list of the
dblookupbombobox) entry. With the shown code it's only possible to entry
known one's.

Thanks in advance.

Andre