Forum > General
what a mistake "tedit can not have tdbgrid as child"
net_goose:
Prompt please, how do I bind to TDBgrid TEdit, using it as a drop-down list with data from database
type
TOraDBGrid = class(TrxDBGrid)
protected
procedure CreateParams(var Params:TCreateParams);override;
procedure KeyDown(var Key: word; Shift: TshiftState);override;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);override;
procedure Open;
public
constructor Create(AOwner:TComponent);override;
destructor Destroy;override;
end;
TOraEdit = class(TEdit)
private
FGrid:TOraDBGrid;
FSession:TOraSession; //TOraSession - компонент ODAC
FSql:String;
...........................
procedure TOraEdit.ShowGrid;
var col:TColumn;
pnt,pnttemp:TPoint;
FullHeigth,FullWidth,ColWidth,H:Integer;
pL,pT:integer;
i:integer;
begin
if Assigned(FGrid) then FGrid.Free;
if not ReadOnly and Enabled then begin
FGrid:=TOraDBGrid.Create(Self);
FGrid.Parent:=Self; //------------------------The error occurs "tedit can not have tdbgrid as child"
FGrid.Font.Assign(Self.Font);
FGrid.Height:=(FGrid.Canvas.TextHeight('*')+3)*10+2;
FGrid.Width:=Width;
with FGrid.Columns do begin
Clear;
FullWidth:=0;
for i:=0 to FShowinfield.Count-1 do begin
col:=Add;
col.FieldName:=FShowinfield;
col.Alignment:=taLeftJustify;
col.Width:=abs(strtoint(FColumnsizelist.Strings));
ColWidth:=col.Width;
FullWidth:=FullWidth+ColWidth;
end;
end;
if FullWidth=0 then begin
FreeAndNil(fGrid); exit;
end else FGrid.Width:=FullWidth+GetSystemMetrics(SM_CXVSCROLL)+2;
pnt:=ClientToScreen(point(0,height));
pL:=pnt.X;
pT:=pnt.Y;
FullWidth:=GetSystemMetrics(SM_CXSCREEN);
FullHeigth:=GetSystemMetrics(SM_CYSCREEN);
if (pT+fgrid.Height)>fullheigth then pT:=pT-fgrid.Height-height-2;
if (pL+fgrid.Width) >fullwidth then pL:=pL-fgrid.width +width;
SetWindowPos(FGrid.Handle, HWND_TOP, pL, pT, 0, 0,SWP_NOSIZE or SWP_NOACTIVATE or SWP_SHOWWINDOW);
FGrid.Visible:=true;
AutoSelect:=false;
SetFocus;
end;
dfeher:
I think you may want to reinvent something. You should use TDBComboBox from 'Data Controls' instead.
net_goose:
Maybe someone knows how to communicate with the developers to clarify this issue? >:(
dfeher:
maybe
--- Code: ---FGrid.Parent:=FGrid;
--- End code ---
helps...
net_goose:
No component may not be an ancestor of itself! ;D
Navigation
[0] Message Index
[#] Next page