Autor Beitrag
D. Annies
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Fr 22.01.10 21:37 
Hi, Delpher,

ich habe eine Proc mit folgender Deklaration:

ausblenden Delphi-Quelltext
1:
procedure TForm1.Excel_Layout2(SG: TStringgrid);					


Jetzt möchte ich aber auch ein DBGrid an diese Proc übergeben. Was muss ich da ändern?
Detlef

_________________
ut vires desint, tamen est laudanda voluntas
Tilman
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1405
Erhaltene Danke: 51

Win 7, Android
Turbo Delphi, Eclipse
BeitragVerfasst: Fr 22.01.10 21:40 
naheliegend wäre
ausblenden Delphi-Quelltext
1:
procedure TForm1.Excel_Layout2(SG: TStringgrid; DBG: TDBGrid);					


schonmal probiert? Oder funktioniert das nicht?

//edit
oder suchst du sowas
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure isStringGrid(grid: TControl);
begin
  if (grid is tStringGrid) then ShowMessage('StringGrid');
  if (grid is tDBGrid) then ShowMessage('DBGrid');
end;

_________________
Bringe einen Menschen zum grübeln, dann kannst du heimlich seinen Reis essen.
(Koreanisches Sprichwort)
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Fr 22.01.10 21:54 
Hi, Tilman,

dein zweiter Vorschlag ist ein Volltreffer!!
Danke, Detlef

_________________
ut vires desint, tamen est laudanda voluntas
Tilman
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1405
Erhaltene Danke: 51

Win 7, Android
Turbo Delphi, Eclipse
BeitragVerfasst: Fr 22.01.10 22:01 
Gerne :)

Wenn du dann damit weiterarbeiten willst musst du es halt noch typecasten. Beispiel:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure irgendwas(grid: TControl);
  var
    sg: TStringGrid;
    dbg: TDBGrid;
begin
  if (grid is TStringGrid) then
  begin
    sg := (grid as TStringGrid);
    sg.machirgendwas
  end;
  [..]
end;

_________________
Bringe einen Menschen zum grübeln, dann kannst du heimlich seinen Reis essen.
(Koreanisches Sprichwort)
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Fr 22.01.10 22:03 
Na, ja, zu früh gefreut:

ausblenden Delphi-Quelltext
1:
2:
if (grid is tStringGrid) then  excel.selection.font.size := Grid.Canvas.Font.Size; //hier Fehlermeldung!
  if (grid is TDBGrid)     then  excel.selection.font.size := 8;


Fehler: Undefinierter Bezeichner Canvas

Idee?

_________________
ut vires desint, tamen est laudanda voluntas
Tilman
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1405
Erhaltene Danke: 51

Win 7, Android
Turbo Delphi, Eclipse
BeitragVerfasst: Fr 22.01.10 22:03 
Ja, siehe oben ^^

_________________
Bringe einen Menschen zum grübeln, dann kannst du heimlich seinen Reis essen.
(Koreanisches Sprichwort)
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Fr 22.01.10 22:13 
Ja, danke
Detlef

_________________
ut vires desint, tamen est laudanda voluntas