Home > Back-end >  To this kind of components, realize the TlistView editable, possible?
To this kind of components, realize the TlistView editable, possible?

Time:10-18

{the following part is the interface definition code}
 unit CustomTListView; 

Interface

USES the
Winapi. Windows System. Classes, Vcl.Com Ctrls, Vcl. StdCtrls, Winapi. Messages, System. UITypes;

Type
TLVEditedEvent=procedure (Sender: TObject; Item: TListItem; The Row, Clm: Integer; Str: string) of the object; {custom message processing method, also do not have what problem}

TTEdit=class (TEdit)//embedded TListView an edit box
Public
//constructor to Create (AOwner: TComponent); Override.
Protected
Procedure WndProc (var message: TMessage); Override.
end;

TTListView=class (TListView)
Private
FEdit: TTEdit;
RowClm: an array of an array of TRect;
EditRow EditClm: Integer;
FOnEditChange: TLVEditedEvent;
The function CalRowClm (X, Y: Integer) : Boolean;//computing procession
Procedure EditRowClm (R, C: Integer);
Procedure WMSetfocus (var message: TMessage); The message WM_KILLFOCUS; {//every time a switch input box, can trigger a focal switch, thus covering the event, from the test, this is no problem}
Protected
Procedure WndProc (var message: TMessage); Override. {hijacked message control process, news operation is no problem of TTlistView}
Procedure DoEditChange (Sender: TObject; Item: TListItem; R, C: Integer; Change: TItemChange); The dynamic;
Public
The constructor Create (AOwner: TComponent); Override.
The destructor Destroy; Override.
Published
//property EditDblClick: TNotifyEvent;//(Sender: TObject); The dynamic;
Procedure EditDblClick (Sender: TObject); Virtual;
The property OnEditChange: TLVEditedEvent read FOnEditChange write FOnEditChange;
end;



{the question now is, how do I, in TTlistView, write a message in response to FEdit event, don't know if I make myself clear? Is in TTListView, define the message event publishing property, covering FEdit inherited events, such as, for example, double click, it is possible? Or am I too dishes? }

CodePudding user response:

I know, embedded Edit, give a listview editor, is easy to implement, the problem is that I want to reuse many times, the editor, in multiple programs, so want to write a component, don't know how to send messages between the two components,

CodePudding user response:

Listview itself is not readonly attribute, you can edit, you want to design is different from this

CodePudding user response:

Listview display data most not itself, is the data specified, so you want to change the data of data, rather than a listview item data, so the editor itself item is invalid,

CodePudding user response:

Delphi is too cold,
I have to put FEdit, moved to the public, let he solved visible, really no better way,