Здесь я не собираюсь обсуждать технологию имплантации DBCombo, так как она практически не отличается от той, что была показана выше. Все написанное в пункте #1 имеет силу и здесь. Вот пошагово разработанный код для вашего компонента.
procedure TForm1.FormCreate(Sender: TObject); begin DBLookupCombo1.Visible := False;DBComboBox1.Visible := False;end; procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect; Field: TField; State: TGridDrawState);begin if (gdFocused in State) thenbeginif (Field.FieldName = DBLookupCombo1.DataField) then beginDBLookupCombo1.Left := Rect.Left + DBGrid1.Left;DBLookupCombo1.Top := Rect.Top + DBGrid1.top;DBLookupCombo1.Width := Rect.Right - Rect.Left;DBLookupCombo1.Visible := True;endelse if (Field.FieldName = DBComboBox1.DataField) thenbeginDBComboBox1.Left := Rect.Left + DBGrid1.Left;DBComboBox1.Top := Rect.Top + DBGrid1.top;DBComboBox1.Width := Rect.Right - Rect.Left;DBComboBox1.Visible := True;endend;end; procedure TForm1.DBGrid1ColExit(Sender: TObject); begin If DBGrid1.SelectedField.FieldName = DBLookupCombo1.DataField thenDBLookupCombo1.Visible := falseelse If DBGrid1.SelectedField.FieldName = DBComboBox1.DataField thenDBComboBox1.Visible := false;end; procedure TForm1.DBGrid1KeyPress(Sender: TObject; var Key: Char); begin if (key <> chr(9)) thenbeginif (DBGrid1.SelectedField.FieldName = DBLookupCombo1.DataField) thenbeginDBLookupCombo1.SetFocus;SendMessage(DBLookupCombo1.Handle, WM_Char, word(Key), 0);endelse if (DBGrid1.SelectedField.FieldName = DBComboBox1.DataField)then beginDBComboBox1.SetFocus;SendMessage(DBComboBox1.Handle, WM_Char, word(Key), 0);end;end;end; |