From a21a18aef60aaf66b5a9bb2ea92eda40a80fc76b Mon Sep 17 00:00:00 2001 From: whookie1 Date: Thu, 6 Oct 2016 12:24:49 +0200 Subject: [PATCH] Fixed bug in issue 663 (Exception pressing return on an edited item with no columns) --- Source/VirtualTrees.pas | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Source/VirtualTrees.pas b/Source/VirtualTrees.pas index 4f3e943af..01f4011a3 100644 --- a/Source/VirtualTrees.pas +++ b/Source/VirtualTrees.pas @@ -32861,17 +32861,18 @@ procedure TVTEdit.WMKeyDown(var Message: TWMKeyDown); // get edit options for column as priority. If column has toDefaultEdit // use global edit options for tree - Column := Tree.Header.Columns[Tree.FocusedColumn]; - if Column.EditOptions <> toDefaultEdit then - EditOptions := Column.EditOptions - else - EditOptions := Tree.TreeOptions.EditOptions; + EditOptions := Tree.TreeOptions.EditOptions; // default + ColumnCandidate := -1; + if Tree.Header.Columns.Count > 0 then // are there any columns? + begin + Column := Tree.Header.Columns[Tree.FocusedColumn]; + if Column.EditOptions <> toDefaultEdit then + EditOptions := Column.EditOptions; - // next column candidate for toVerticalEdit and toHorizontalEdit - if Column.EditNextColumn <> -1 then - ColumnCandidate := Column.EditNextColumn - else - ColumnCandidate := -1; + // next column candidate for toVerticalEdit and toHorizontalEdit + if Column.EditNextColumn <> -1 then + ColumnCandidate := Column.EditNextColumn; + end; case EditOptions of toDefaultEdit: Tree.SetFocus;