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: Sa 04.12.10 08:40 
Hi, Delpher,
ich brauche mal eine Idee:
Wie kann man am elegantesten aus einem Stringgrid selektieren?
Ich will also SQL-Befehle nachahmen, z.B. den Folgenden:

select * from TbS where Klasse = '7a';

Wie geht das?

_________________
ut vires desint, tamen est laudanda voluntas
bummi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1248
Erhaltene Danke: 187

XP - Server 2008R2
D2 - Delphi XE
BeitragVerfasst: Sa 04.12.10 10:43 
das wird kein 3/4 Stunden Projekt ;-)
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
Type
TResultArray=Array of Array of Variant; // oder String

Function StringGridSQL(SG:TStringGrid;const SQL:String):TResultArray;
var
  i,rows,cols:Integer;
begin
   // Felder Parsen oder bei * cols = Grid.Colcomut  + hier vielleicht ein zusätziches "Feld" für dir RowNumber
   for I := 0 to SG.RowCount - 1 do
      begin
        // Wenn Bedingung erfüllte dann
        inc(rows);
        Setlength(Result,rows + 1, Cols);
        // Zellwerte eintragen
      end;
   // in Result[0][0..cols] die Feldnamen eintragen
   // Result[1] bis Result[rows-1] sortieren nach Order by vorschrift

end;

_________________
Das Problem liegt üblicherweise zwischen den Ohren H₂♂
DRY DRY KISS
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: So 05.12.10 11:12 
Hi, Bummi,
das bringt mich so leider nicht weiter, trotzdem danke.
Ich habe jetzt den folgenden Code:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
procedure TBuchMain.BuchstatusdieserGruppe1Click(Sender: TObject);
begin
  tnt3init(self);
  TntStringgrid1selectcell; // ???;
  button44click(self);
end;

procedure TBuchMain.TntStringGrid1SelectCell(Sender: TObject; ACol,
  ARow: Integer; var CanSelect: Boolean);
var n : smallint;
begin
  n := -1;
  repeat
    inc(n);
  until listbox1.Items[n] = tntstringgrid1.cells[aCol,aRow];   // z.B. '10c';
  listbox1.ItemIndex := n;
end;


Wie kann ich die Proc TntStringgrid1selectcell in BuchstatusdieserGruppe aufrufen?
Bis denne,
Detlef

_________________
ut vires desint, tamen est laudanda voluntas
bummi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1248
Erhaltene Danke: 187

XP - Server 2008R2
D2 - Delphi XE
BeitragVerfasst: So 05.12.10 13:08 
Ich verstehe a nicht was das mit der Ausgangsfrage zu tun hat und b was Du vorhast.
Warum willst Du ein Event aufrufen welches vom Grid gefeuert wird bei selektieren einer Zelle, die Aufrufparameter stehen 4 Zeilen drunter

TntStringGrid1SelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean)

aber was willst Du da warum übergeben....

_________________
Das Problem liegt üblicherweise zwischen den Ohren H₂♂
DRY DRY KISS
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: So 05.12.10 20:28 
Hi, Bummi,
schade, wenn es etwas unverständlich war: Die Daten habe ich mittlerweile in dem Stringgrid,
als Filter aus einem xls-File; und jetzt kann ich durch Anklicken einer bestimmten Zelle
weitere Infos aus dem (Rest-)Programm holen.
Manchmal reicht es schon, wenn man darüber spricht - (das Gesamtprg ist schon etwas komplexer
mit ca. 7000 Zeilen.
Danke dir nochmal für deine Mühe,
Detlef

_________________
ut vires desint, tamen est laudanda voluntas