Autor Beitrag
etz472
Hält's aus hier
Beiträge: 4



BeitragVerfasst: So 19.01.03 17:54 
Hallo!

Wenn ich auf eine Zelle eines StringGrids doppelklicke, soll der Inhalt eines Editfeldes dort reingeschrieben werden.
Mit dem Ereignis OnSelectCell funktioniert das nur bei Einfachklick. Gibt es eine Möglichkeit, dass es auch bei Doppelklick funktioniert?
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: So 19.01.03 17:59 
Wenn kein entsprechendes Ereignis (OnDblClick) gibt, kannste ja selbst eins bauen, mithilfe eines Timers. Select-Cell setzt eine Boolean-Variable, aktiviert den Timer, der Timer setzt die Variable zurück. Wenn der Anwender jetzt nochmal klickt, bevor der Timer die Variable zurückgesetzt hat, dann haste Deinen Doppelklick. Ok, das setzt dann natürlich voraus, dass jeder Klick das Select-Cell-Event aufruft *grübel*.

Nur mal kurz so ne Idee... kanns grad net testen....

Gruß
derDoc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 623

Win Vista Prof
D2007 Prof
BeitragVerfasst: So 19.01.03 18:12 
Es geht einfacher, indem du beide Ereignisse kombinierst:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
var
  Form1: TForm1;
  row, col: Integer;

implementation

{$R *.dfm}

procedure TForm1.StringGrid1DblClick(Sender: TObject);
begin
  StringGrid1.Cells[col, row] := Edit1.Text;
end;

procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol,
  ARow: Integer; var CanSelect: Boolean);
begin
  col := ACol;
  row := ARow;
end;


Da du bei einem Doppelklick auch selektierst kannst du beides zusammenführen.

_________________
MfG derDoc
There are only 10 types of people: those who understand binary and those who don't.
etz472 Threadstarter
Hält's aus hier
Beiträge: 4



BeitragVerfasst: So 19.01.03 21:54 
Titel: Danke!
Super, das funktioniert! Danke!! :D