Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi Eigener Dialog+TOpendialog Umbenennen Funktion über F2 Taste (https://www.delphipraxis.net/42135-eigener-dialog-topendialog-umbenennen-funktion-ueber-f2-taste.html)

Luckie 14. Mär 2005 15:27

Re: Eigener Dialog+TOpendialog Umbenennen Funktion über F2 T
 
Das kann doch nicht so schwer sein:
Zitat:

Write an OnEdited event to take specific action when a user has finished editing the text of a list item. An OnEdited event handler can respond to the value the user typed, or change the value that is assigned to the list item’s Caption property. For example, if an OnEdited event handler can check the validity of the string typed by the user, and only allow the Caption property to be changed if the new value is valid.

The Item parameter is the list item that was just edited. The S parameter is the new value the user typed for the item’s Caption property. Change the value of S to override the value the user typed. When OnEdited occurs, the item’s Caption property has not yet been changed, so S can still be compared to the original value of Caption.

This event can occur only if ReadOnly is set to False.

eassy 14. Mär 2005 15:40

Re: Eigener Dialog+TOpendialog Umbenennen Funktion über F2 T
 
schwer --> doch irgendwie schon.... :drunken:

da ich nicht mal in den editiermodus durch drücken der f2-taste komme.

:wall: :wall: :wall:

bitte hilfe....

Luckie 14. Mär 2005 15:45

Re: Eigener Dialog+TOpendialog Umbenennen Funktion über F2 T
 
Einfach m,al etwas intensiver in der Hilfe gucken. Ich habe es auch nicht gewußt, aber sie da, was ich mittels der Hilfe geschaft habe:
Delphi-Quellcode:
procedure TForm1.ListView1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key = VK_F2 then
  begin
    Listview1.Selected.EditCaption;
  end;
end;

eassy 14. Mär 2005 15:49

Re: Eigener Dialog+TOpendialog Umbenennen Funktion über F2 T
 
:firejump: vielen vielen dank. :firejump:
es klappt....

Luckie 14. Mär 2005 15:51

Re: Eigener Dialog+TOpendialog Umbenennen Funktion über F2 T
 
Und hier alles zusammen:
Delphi-Quellcode:
type
  TForm1 = class(TForm)
    ListView1: TListView;
    procedure ListView1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure ListView1Edited(Sender: TObject; Item: TListItem;
      var S: String);
  private
    { Private declarations }
    CptBeforeEdt: String;
    CptAfterEdt: String;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.ListView1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key = VK_F2 then
  begin
    Listview1.Selected.EditCaption;
    CptBeforeEdt := Listview1.Items[Listview1.ItemIndex].Caption;
  end;
end;

procedure TForm1.ListView1Edited(Sender: TObject; Item: TListItem;
  var S: String);
begin
  CptAfterEdt := s;
  ShowMessage(Format('RenameFile(%s, %s)', [CptBeforeEdt, CptAfterEdt]));
end;


Alle Zeitangaben in WEZ +1. Es ist jetzt 15:44 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz