Recent

Author Topic: TListView OnChanging event  (Read 2490 times)

timppl

  • Jr. Member
  • **
  • Posts: 80
TListView OnChanging event
« on: December 22, 2014, 08:40:43 am »
Hello all

In delphi, the TListView has an OnChanging event which is fired at the start of editing to see if the editing should be allowed.  This event does not exist in the LCL version so I thought I would have a go at adding it.

I tried subclassing it ( in one of my project files )

Code: [Select]
TLVChangingEvent = procedure (Sender: TObject; Item: TListItem;
   Change: TItemChange; var AllowChange: Boolean) of object;

   TTLListView = class(TListView)
   private
      FOnChanging: TLVChangingEvent;
      protected
      property OnChanging: TLVChangingEvent read FOnChanging write FOnChanging;
      end;

but this did not work, so I assume that I need to change the source in the LCL.

However I am a bit ( well, a lot really  :-[ ) hazy about how the events are triggered. I have read the various wiki pages on widget writing but am no wiser. Can someone point me to any further resources so I can have a go at it over the holiday.

I suppose that it may not be possible to add this event, in which case I will have to do a work-around, so that will be useful to know as well.
 

Regards

Tim
Mageia 8 Linux on x86

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: TListView OnChanging event
« Reply #1 on: December 22, 2014, 11:03:19 am »
The Lazarus TListView has an OnEditing event property
Code: [Select]
TLVEditingEvent = procedure(Sender: TObject; Item: TListItem;
    var AllowEdit: Boolean) of object; 

Can you not use this, rather than reinvent the wheel?

timppl

  • Jr. Member
  • **
  • Posts: 80
Re: TListView OnChanging event
« Reply #2 on: December 22, 2014, 11:19:34 am »
Hi Howard

I had seen that, but I was/am not sure just when it fires relative to the delphi OnChanging, although it appears from the embarcadero docs online that the OnEditing applies only to the caption property and the OnChanging to any item in the list.

Regards

Tim
Mageia 8 Linux on x86

 

TinyPortal © 2005-2018