| Autor |
Beitrag |
fuggaz
      
Beiträge: 106
|
Verfasst: Di 25.09.07 17:53
Hallo,
Mit einer Taste kann der Benutzer der Zelle, in der er gerade im Stringgrid arbeitet, eine Text hinzufügen.
Das funktioniert auch. Bloß wird dann automatisch der Text in der Zelle markiert und das will ich nicht.
Gibt es eine Funktion zum entmarkieren des Textes?
mfg fuggaz
|
|
fuggaz 
      
Beiträge: 106
|
Verfasst: Di 25.09.07 20:36
Kann ich vllt. irgendwie den Cursor positionieren?
Dann würde die Markierung ja aufgehoben.
|
|
Lannes
      
Beiträge: 2352
Erhaltene Danke: 4
Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
|
Verfasst: Mi 26.09.07 09:40
Hallo,
dazu muss man Zugriff auf den InplaceEditor des Grids bekommen.
im etwa so:
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8:
| Type THackGrid = class(TCustomGrid); private FGrid : THackGrid; StringGrid.SetFocus; StringGrid.EditorMode := True; FGrid.InplaceEditor.SelStart := Length(FGrid.InplaceEditor.Text); |
_________________ MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
|
|
fuggaz 
      
Beiträge: 106
|
Verfasst: Mi 26.09.07 11:54
Danke für deine Antwort.
Leider bekomme ich dann eine Zugriffsverletzung.
(FGrid.InplaceEditor.SelStart := Length(FGrid.InplaceEditor.Text)
Ne Idee?
|
|
Lannes
      
Beiträge: 2352
Erhaltene Danke: 4
Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
|
Verfasst: Mi 26.09.07 22:25
Hallo,
ja
Du zeigst mal wie und wo Du das in Deinen Code eingebaut hast.
_________________ MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
|
|
fuggaz 
      
Beiträge: 106
|
Verfasst: Do 27.09.07 00:02
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:
| uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Grids;
type THackGrid = class(TCustomGrid); TForm1 = class(TForm) StringGrid: TStringGrid; procedure einfuegen(Sender: TObject; var Key: Word; Shift: TShiftState); private FGrid : THackGrid; { Private-Deklarationen } public { Public-Deklarationen } end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.einfuegen(Sender: TObject; var Key: Word; Shift: TShiftState); begin if key=vk_f4 then begin StringGrid.SetFocus; StringGrid.EditorMode := True; FGrid.InplaceEditor.SelStart := Length(FGrid.InplaceEditor.Text); end; end;
end. |
|
|
Lannes
      
Beiträge: 2352
Erhaltene Danke: 4
Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
|
Verfasst: Do 27.09.07 00:22
Hallo,
sorry, hab noch was vergessen
In FormCreate muss noch die Variable FGrid initialisiert werden:
Delphi-Quelltext 1:
| FGrid := THackGrid(StringGrid1); |
_________________ MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
|
|
fuggaz 
      
Beiträge: 106
|
Verfasst: Do 27.09.07 00:58
Super!
Es funktionier jetzt:)
Danke!!
mfg fuggaz
|
|
|