Hello Forum:
Following this
tutorial, I've been able to use the DB components that come with Lazarus and placing a DBLookupComboBox inside a DBGrid has always worked seamlessly. But a few days ago, I switched to Rx DB components and the same tutorial code now fails. And since there are properties in the standard Lazarus DBLookupComboBox that aren't in the TRxDBLookupCombo, properties used in the tutorial, I've only been able to work with the TRxDBGrid and the Laz DBLookupComboBox. The TRxDBGrid is more robust than Lazarus' stock DBGrid, so I'd like to be able to use it.
What happens when I use the tutorial code with the TRxDBGrid is incredible. I have just one row (for testing) in the table that was to load in the grid. All
looked okay. But as soon as I added the code for
OnDrawColumnCell, my only row of data disappeared. Now I cld double click in the cells and the data wld highlight, my data magically appearing. But when I'd move to another cell, it'd disappear again.
procedure TForm_Main.DBGrid_AddItemsDrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if (gdFocused in State) then
begin
if (Column.Field.FieldName = DBLookupComboBox_InventoryUnit.DataField) then
with DBLookupComboBox_InventoryUnit do
begin
Left := Rect.Left + DBGrid_AddItems.Left + 2;
Top := Rect.Top + DBGrid_AddItems.Top + 2;
Width := Rect.Right - Rect.Left;
Width := Rect.Right - Rect.Left;
Height := Rect.Bottom - Rect.Top;
Visible := True;
end;
end
end;
I use several other of these TRxDBGrids, less the DBLookupComboBox, and they work like a DBGrid's suppose to. Even the Grid in question works, right up until I wire in the above-noted procedure. Then it all falls apart. Obviously I'm not smart enough to understand why that procedure works with Lazarus' stock TDBGrid and TDBLookupComboBox and craps out with the TRxDBGrid and a TDBLookupComboBox.
I hope someone can/will explain to me why my data's disappearing from the grid when i use that procedure? Thanks.
**************************************************************************************************************************************
Components in question are:
TRxDBGridTDBLookupComboBox