Autor Beitrag
bruder jonas
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 76



BeitragVerfasst: Do 24.04.03 20:25 
hallo,

ich habe ein grid mit 2 spalten. wie kriege ich den wert der ersten spalte des grids, ds gerade markiert ist?

danke
grayfox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 800

win98, winXP
D4 Standard; D6 Personal
BeitragVerfasst: Do 24.04.03 20:53 
hallo bruder jonas!

wenn das dbgrid daten aus einem table zeigt, dann mit
ausblenden Quelltext
1:
table1.FieldByName('Name_des_ersten_Feldes').asIrgendwas					

wenns an einer Query hängt, dann
ausblenden Quelltext
1:
2:
{$UNTESTED}
query1.FieldByName('Name_des_ersten_Feldes').asIrgendwas


mfg, stefan
kiwicht
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1021

Win 7, MacOS
Delphi x, VBA, PHP, ...
BeitragVerfasst: Do 24.04.03 21:06 
und wenn du nicht weis, wie diese Feld heist, weil dynamisch, dann:

ausblenden Quelltext
1:
2:
3:
string1 := mygrid.SelectedField.FieldName;

string2 := query.fieldbyname(string1).AsString;


(not yet tested, but just developed NYTBJD - NÜTBID ;) )

mfg

(btw: query.fieldvalues['blahfeld']...)
LCS
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1305
Erhaltene Danke: 1

WIN 7, WIN 8
Delphi XE5, Delphi XE, Delphi 2007
BeitragVerfasst: Fr 25.04.03 06:24 
Hi
Oder noch einfacher. Zugriff auf das gerade ausgewählte Feld:
ausblenden Quelltext
1:
 Variable := grid.SelectedField.Value;					

Aber aufpassen: SelectedField kann auch nil sein, wenn eine ganze Zeile markiert wurde.

Zugriff auf eine bestimmte Spalte
ausblenden Quelltext
1:
  Variable := grid.Columns[i].Field.Value;					


Gruss Lothar

_________________
Der BH ist für die Brust, der Plan ist für'n Ar...
bruder jonas Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 76



BeitragVerfasst: Fr 25.04.03 06:39 
Titel: danke euch
vielen dank für die schnelle hilfe

jonas