Board index » delphi » Triggering OnEdited event

Triggering OnEdited event

Hi

How can I trigger the TListView.OnEdited event by code? This event is
being triggered just by key input, not by change done by code.

-Janos

 

Re:Triggering OnEdited event


Have you tried calling it ?

procedure TForm1.ListView1Editing(Sender: TObject; Item: TListItem; var
AllowEdit: Boolean);
begin
 showmessage('Hi');
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  SomeBoolean: boolean;
begin
  ListView1Editing(Sender, ListView1.Selected, SomeBoolean);
end;

Quote
Jnos Schmidt wrote:
> Hi

> How can I trigger the TListView.OnEdited event by code? This event is
> being triggered just by key input, not by change done by code.

> -Janos

  GuidoG_at_work.vcf
< 1K Download

Re:Triggering OnEdited event


The situation is following:

1. I call TListItem.EditCaption.
2. There may be a changing input or just a RETURN-key.
3. In case of a real change the OnEdited event is activated, but in case
of  the RETURN-key NOT, and this is exactly my problem.
4. If I call the assigned procedure of OnEdited after EditCaption, the
EditCaption is terminated BEFORE any input, and this is not desireable.

Do you have another idea, for this?

Janos

Re:Triggering OnEdited event


Show us some of your code so we could suggest something.

JinTonic

Jnos Schmidt <janos.schm...@swisslife.ch> D???
???Y??:3912B0BD.BBF77...@swisslife.ch...

Quote
> The situation is following:

> 1. I call TListItem.EditCaption.
> 2. There may be a changing input or just a RETURN-key.
> 3. In case of a real change the OnEdited event is activated, but in case
> of  the RETURN-key NOT, and this is exactly my problem.
> 4. If I call the assigned procedure of OnEdited after EditCaption, the
> EditCaption is terminated BEFORE any input, and this is not desireable.

> Do you have another idea, for this?

> Janos

Re:Triggering OnEdited event


Hi

Here's the important part of the code:

var
  DocumentList: TListView;
  DocumentItem: TListItem;
  SaveDocument: TListItem;

procedure TDocForm.InsertDocumentClick(Sender: TObject);
begin
  // .................

  if DocumentIsCopied then
  // Insert DocumentItem in DocumentList
  begin
    DocumentList.ReadOnly  := False;
    DocumentItem := DocumentList.Items.Add;
    DocumentItem.Caption := SaveDocument.Name;
    DocumentItem.Data := nil;

    DocumentItem.EditCaption;
    // -------------------------
    // Here I need OnEdited to be activated,
    // even if the input is just the RETURN-key
    // to avoid duplicate names, i.e. to have a chance
    // to create an artificial name instead.
    // -------------------------

  end;

  // .................
end;

Re:Triggering OnEdited event


Try this:

var
  s: string;
begin
  // .................

  if true then
  // Insert DocumentItem in DocumentList
  begin
    DocumentList.ReadOnly  := False;
    DocumentItem := DocumentList.Items.Add;
    DocumentItem.Caption := SaveDocument.Name;
    DocumentItem.Data := nil;
    DocumentItem.EditCaption;

      s:=SaveDocument.Name;
      while Documentlist.IsEditing do application.processmessages;
      DocumentList.OnEdited(Self,DocumentItem,s);

  end;

  // .................
end;

JinTonic

Re:Triggering OnEdited event


Fine, it's working! - Lot of thanks!

Janos

Other Threads