Skip to content

Bugfix: Exception when pressing return on an item with no additional columns #663

@whookie1

Description

@whookie1

There is an exception raised, when using VirtualStringTree as a tree only (no additional columns) and pressing return-key after editing a tree-item @ the following line (VirtualTrees.pas::32867):

Column := Tree.Header.Columns[Tree.FocusedColumn];

this is, because Tree.FocusedColumn is -1 at that moment!

You can fix this by changing lines 32867 to 32877:

          Column := Tree.Header.Columns[Tree.FocusedColumn];           <-EXCEPTION
          if Column.EditOptions <> toDefaultEdit then
            EditOptions := Column.EditOptions
          else
            EditOptions := Tree.TreeOptions.EditOptions;

         // next column candidate for toVerticalEdit and toHorizontalEdit
         if Column.EditNextColumn <> -1 then
            ColumnCandidate := Column.EditNextColumn
          else
            ColumnCandidate := -1;

with the following block:

          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;
          end;

Metadata

Metadata

Assignees

Labels

BugPull Requests InvitedThere are no current plans to address the issue, but we would be happy if someone supplies a PR.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions