TAdvTreeView - Custom Editing

Another query about this component...

Rather than using the built in editors, I need to use a custom editor (mainly a TMS TAdvEdit component - to enable me to set alignment, edit type (numeric/float/etc) and generally have more control over the edit)

This works well, but how do I 'stop' the editing? With a built in editor (tcetEdit), pressing RETURN stops the edit and updates the node accordingly. With the custom editor, the only way to stop the edit and hide the edit component seems to be by clicking another node on the treeview.

Also, and this applies to the built in editors too, as well as custom editors, pressing TAB or losing focus from the edit control, doesn't stop the edit either, but simply moves to the next control on the form (keeping the edit box open).

Is there a way of telling the TAdvTree view to stop editing and hide the edit component? If so, I could possibly implement an OnKeyPress to my custom editor to check for RETURN etc to stop the edit.

Hi, 


You will need to manually assign the OnKeyPress and handle the Return key, to stop editing and accept the value you can use AdvTreeView1.StopEditing; to stop editing and cancel use AdvTreeView1.CancelEditing

Kind Regards, 
Pieter

Hi, thanks for the suggestion. However, if I put a call to StopEditing in the OnKeyPress to handle RETURN, pressing RETURN does close the editor, but then immediately opens it again. I assume the RETURN is also being processed by the AdvTreeView, which then re-opens the edit.


Hi, 


To stop editing correctly, please use the OnKeyUp event

procedure TForm1.DoKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
  case Key of
    VK_RETURN: AdvTreeView1.StopEditing;
  end;
end;

Kind Regards, 
Pieter