hallöchen...
hab n "lustiges" problem bei der Abfrage meiner Tabelle, bezüglich der angeklickten spalte. das ganze läuft über die OnDblClick-Proc des Grids.
Und zwar passiert folgendes: wenn ich auf die erste Spalte clicke, klappts wunderbar, clicke ich auf die 2., gehts auch, clicke ich auf die dritte, erkennt er diese als 4. usw., hier ne übersicht:
1. spalte -> erkannt als 1.
2. spalte -> erkannt als 2.
3. spalte -> erkannt als 4.
4. spalte -> gar nicht erkannt
5. spalte -> erkannt als 3.
6. spalte -> gar nicht erkannt
hier der Code, der in meinem Prog auf mein Grid zugreift:
und zwar die init. der tabelle ansich, bei Form1.Create
Quelltext
1: 2: 3: 4: 5: 6: 7: 8:
| with grArtmat do begin Columns[0].FieldName := 'Text'; Columns[1].FieldName := 'Stueck'; Columns[2].FieldName := 'Listpreisv'; Columns[3].FieldName := 'Preisgr'; Columns[4].FieldName := 'Lagerort'; Columns[5].FieldName := 'Artiklnumr'; end; |
und hier die abfrage, welches feld geklickt wurde, um dannzu sortieren:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37:
| if grArtmat.SelectedField.Index = 1 then begin qMatBestand.SQL.Clear; qMatBestand.SQL.Add(SQLText); label1.Caption := '1'; qMatBestand.SQL.Add(' ORDER BY text') end else
if grArtmat.SelectedField.Index = 2 then begin qMatBestand.SQL.Clear; qMatBestand.SQL.Add(SQLText); label1.Caption := '2'; qMatBestand.SQL.Add(' ORDER BY stueck') end else
if grArtmat.SelectedField.Index = 3 then begin qMatBestand.SQL.Clear; qMatBestand.SQL.Add(SQLText); label1.Caption := '3'; qMatBestand.SQL.Add(' ORDER BY Listpreisv') end else
if grArtmat.SelectedField.Index = 4 then begin qMatBestand.SQL.Clear; qMatBestand.SQL.Add(SQLText); label1.Caption := '4'; qMatBestand.SQL.Add(' ORDER BY Preisgr') end else
if grArtmat.SelectedField.Index = 5 then begin qMatBestand.SQL.Clear; qMatBestand.SQL.Add(SQLText); label1.Caption := '5'; qMatBestand.SQL.Add(' ORDER BY Lagerort') end else
if grArtmat.SelectedField.Index = 6 then begin qMatBestand.SQL.Clear; qMatBestand.SQL.Add(SQLText); label1.Caption := '6'; qMatBestand.SQL.Add(' ORDER BY Artiklnumr') end;
qMatBestand.Open; |
ich hab auch schon probiert, in den if-Abfragen bei null zu beginnen, klappt aber genauso wenig...
wär ganz nett wenn einer n lösungs-ansatz findet..
mfg kiwicht