Board index » delphi » TListView.OnEdited enigma

TListView.OnEdited enigma

Hi folks!

I've got a strange problem:

Consider that I have a TListView called lv, and clicking on it, I'll add a
ListItem and put it on Edit state calling EditCaption method.
Since I just want to continue my procedure after the item was edited, I've
created a global var named "ok", and after calling the EditCaption method, I
did a looping to wait this var went to true. Ok is set to true on the
TListView.OnEdited event handler.

Problem:
Until here, everything is fine, everything works, but when I click on the
listview and simply press ENTER, without writing anything on the
listitem.caption, it don't call onEdited event handler, and worse, it never
close the looping.

The source code is beneath:

var
  ok: boolean;

procedure TForm1.lvClick(Sender: TObject);
var
  added: TListItem;
begin
  added := lv.Items.Add;
  ok := false;
  added.EditCaption;
  while not ok do
    Application.ProcessMessages;
  showmessage('Item inserted');
end;

procedure TForm1.lvEdited(Sender: TObject; Item: TListItem; var S: String);
begin
  ok := true;
end;

thanks

Padu

 

Re:TListView.OnEdited enigma


Paul,

the onedited event is called when the text is changed, not when you enter
with the text onchanged ...

Jan Jacobs

TsjaT...@hotmail.com
Padu - Paulo Eduardo Merloti heeft geschreven in bericht
<78a0g1$j...@forums.borland.com>...

Quote
>Hi folks!

>I've got a strange problem:

>Consider that I have a TListView called lv, and clicking on it, I'll add a
>ListItem and put it on Edit state calling EditCaption method.
>Since I just want to continue my procedure after the item was edited, I've
>created a global var named "ok", and after calling the EditCaption method,
I
>did a looping to wait this var went to true. Ok is set to true on the
>TListView.OnEdited event handler.

>Problem:
>Until here, everything is fine, everything works, but when I click on the
>listview and simply press ENTER, without writing anything on the
>listitem.caption, it don't call onEdited event handler, and worse, it never
>close the looping.

>The source code is beneath:

>var
>  ok: boolean;

>procedure TForm1.lvClick(Sender: TObject);
>var
>  added: TListItem;
>begin
>  added := lv.Items.Add;
>  ok := false;
>  added.EditCaption;
>  while not ok do
>    Application.ProcessMessages;
>  showmessage('Item inserted');
>end;

>procedure TForm1.lvEdited(Sender: TObject; Item: TListItem; var S: String);
>begin
>  ok := true;
>end;

>thanks

>Padu

Re:TListView.OnEdited enigma


Ok, I realized that, but do you know how to do that?
Or how do I know when the EditCaption exited without change. I've tryed with
KeyDown, but TListView doesn't appear to take note that I've pressed Enter
if I haven't changed the EditCaption.

Thank you Jan

Padu

Quote
fdfq wrote in message <78evud$n...@forums.borland.com>...
>Paul,

>the onedited event is called when the text is changed, not when you enter
>with the text onchanged ...

>Jan Jacobs

>TsjaT...@hotmail.com
>Padu - Paulo Eduardo Merloti heeft geschreven in bericht
><78a0g1$j...@forums.borland.com>...
>>Hi folks!

>>I've got a strange problem:

>>Consider that I have a TListView called lv, and clicking on it, I'll add a
>>ListItem and put it on Edit state calling EditCaption method.
>>Since I just want to continue my procedure after the item was edited, I've
>>created a global var named "ok", and after calling the EditCaption method,
>I
>>did a looping to wait this var went to true. Ok is set to true on the
>>TListView.OnEdited event handler.

>>Problem:
>>Until here, everything is fine, everything works, but when I click on the
>>listview and simply press ENTER, without writing anything on the
>>listitem.caption, it don't call onEdited event handler, and worse, it
never
>>close the looping.

>>The source code is beneath:

>>var
>>  ok: boolean;

>>procedure TForm1.lvClick(Sender: TObject);
>>var
>>  added: TListItem;
>>begin
>>  added := lv.Items.Add;
>>  ok := false;
>>  added.EditCaption;
>>  while not ok do
>>    Application.ProcessMessages;
>>  showmessage('Item inserted');
>>end;

>>procedure TForm1.lvEdited(Sender: TObject; Item: TListItem; var S:
String);
>>begin
>>  ok := true;
>>end;

>>thanks

>>Padu

Other Threads