Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi TDBGrid -> String in TDBGrid (https://www.delphipraxis.net/98735-tdbgrid-string-tdbgrid.html)

HolgerCW 31. Aug 2007 13:36


TDBGrid -> String in TDBGrid
 
Hallo zusammen,

ich habe den Namen eines DBGrids als String. Wie kann ich nun dieses DBGrid als TDBGrid an eine Funktion übergeben ?

Gruss

Holger

Ghostwalker 31. Aug 2007 13:53

Re: TDBGrid -> String in TDBGrid
 
Über die Components-Auflistung des Parents (oder wars der Owner ? Da komm ich immer durcheinander), kannst du die Namen vergleichen und das entsprechende Objekt holen :)

Also in etwas so:

Delphi-Quellcode:
function SearchDBGrid(Name:string):TDBGrid;
var
  I : integer
begin
  result := NIL;
  for i := 0 to form1.componentcount -1 do
  begin
    if (form1.components[i] is TDBGrid) and (TDBGrid(Form1.components[i]).name = 'Hierdeinname') then
      result := TDBGrid(form1.components[i]);
  end;
end;

HolgerCW 31. Aug 2007 15:15

Re: TDBGrid -> String in TDBGrid
 
Vielen dank,

das klappt super

Gruss

Holger


Alle Zeitangaben in WEZ +1. Es ist jetzt 22:18 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz