Autor Beitrag
Andi1982
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 497

WinXP HE
D6 Enterprise
BeitragVerfasst: Mi 04.06.03 16:44 
Hallo,
ich habe im OnKeyPrss Ereignis meines DBGrid's Folgendes stehen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.DBGrid1KeyPress(Sender: TObject; var Key: Char);
begin
   If key = #13 then DBGrid1DblClick(Form1);
end;


Auf die if-Abfrage habe ich einen Breakpoint gesetzt. wenn ich jetzt aber im dbgrid bin und enter oder eine andere Taste drücke wird dieses Ereignis garnicht aufgerufen. Warum geht das hier nicht???

Gruss Andi

_________________
Solange die Bombe tickt ist alles in Ordnung, erst wenn sie damit aufhört wird es problematisch...
Tweafis
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 647

WinXP + fbsd
Delphi 5 Prof
BeitragVerfasst: Mi 04.06.03 16:48 
Hast du das Event deinem DBGrid zugewiesen?

Bei mir funzts nämlich und der Breakpoint auch.

Fis

_________________
.: Es wird der Tag kommen, an dem wir es nicht mehr ändern können :.
Andi1982 Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 497

WinXP HE
D6 Enterprise
BeitragVerfasst: Mi 04.06.03 16:52 
Oh, hab den Fehler:

Onlinehilfe hat folgendes geschrieben:
OnKeyDown Tritt auf, wenn ein Benutzer eine Taste oder eine Tastenkombination drückt, während das Gitter den Fokus besitzt.
OnKeyPress Tritt auf, wenn der Benutzer eine einzelne alphanumerische Taste drückt, während das Gitter den Fokus besitzt.


enter-taste ist nicht alphanumerisch!!

Habs jetzt so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.DBGrid1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
   if Key = #13 then DBGrid1DblClick(Form1);
end;


aber ich bekomm dann den fehler "inkompatible Typen" Warum???

_________________
Solange die Bombe tickt ist alles in Ordnung, erst wenn sie damit aufhört wird es problematisch...
Tweafis
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 647

WinXP + fbsd
Delphi 5 Prof
BeitragVerfasst: Mi 04.06.03 16:53 
Key ist vom Typ word, also nur 13 bzw VK_ENTER

_________________
.: Es wird der Tag kommen, an dem wir es nicht mehr ändern können :.
Andi1982 Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 497

WinXP HE
D6 Enterprise
BeitragVerfasst: Mi 04.06.03 16:57 
Aber auch bei dem Ereignis OnKeyDown wird bei der entertaste nicht betreten :cry:

_________________
Solange die Bombe tickt ist alles in Ordnung, erst wenn sie damit aufhört wird es problematisch...
Andi1982 Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 497

WinXP HE
D6 Enterprise
BeitragVerfasst: Mi 04.06.03 17:03 
Oh,
so gehts:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.DBGrid1KeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
   if key = 13 then DBGrid1DblClick(Form1);
end;


Aber jetzt hab ich ein anderes problem. Wenn man den Focus auf DBGrid hat und Enter drückt, springt der Cursor auf die erste Zeile des DBGrid's.

Kann man das nicht irgendwie unterdrücken????

_________________
Solange die Bombe tickt ist alles in Ordnung, erst wenn sie damit aufhört wird es problematisch...