In the FormActivate, I have:
DM1.DS_UnitComboBox.DataSet := DM1.ZQ_UnitComboBox;
DM1.ZQ_UnitComboBox.Connection := DM1.ZConn
RxUnitComboBox.DataSource := DM1.DS_UnitComboBox;
with RxUnitComboBox do
begin
DataField := 'inventory_unit';
Visible:= False;
end;
For the DBGrid, I have:
procedure TForm_Neo.RxDBGrid_AddItemsSelectEditor(Sender: TObject;
Column: TColumn; var Editor: TWinControl);
begin
try
if Column.FieldName = RxUnitComboBox.DataField then
begin
Editor := RxUnitComboBox;
end;
except
On e: Exception do
MessageDlg('Error during TForm_Main.DBGrid_AddItemsSelectEditor event: ' +
e.Message, mtWarning,[mbOK],0);
end;
Editor.BoundsRect := RxDBGrid_AddItems.SelectedFieldRect;
end;
For the DBCombobox (Style := csDropDown):
procedure TForm_Neo.RxUnitComboBoxKeyPress(Sender: TObject; var Key: char);
begin
if key = #13 then
try
if RxDBGrid_AddItems.SelectedIndex + 1 < RxDBGrid_AddItems.Columns.Count then
RxDBGrid_AddItems.SelectedIndex := RxDBGrid_AddItems.SelectedIndex + 1;
except
On e: Exception do
MessageDlg('Error during TForm_Neo.RxUnitComboBoxKeyPress event: ' +
e.Message, mtWarning,[mbOK],0);
end;
end;
And I get no DBCombobox in the DBGrid. I can enter data in the cell and it gets saved. But I just don't get the DBCombobox.
But, if I change the DBGrid code to
procedure TForm_Neo.RxDBGrid_AddItemsSelectEditor(Sender: TObject;
Column: TColumn; var Editor: TWinControl);
begin
try
if Column.Field = RxUnitComboBox.Field then // NOTE THE CHANGE TO THIS LINE
begin
Editor := RxUnitComboBox;
end;
except
On e: Exception do
MessageDlg('Error during TForm_Main.DBGrid_AddItemsSelectEditor event: ' +
e.Message, mtWarning,[mbOK],0);
end;
Editor.BoundsRect := RxDBGrid_AddItems.SelectedFieldRect;
end;
then I get a DBCombobox in the Grid. But it accepts no data. No matter what I type in it, it gets wiped out when I exit the cell.