TAdvTreeView SelectedNode

I am having a few difficulties with the TAdvTreeView (in TMS Compoenents
8.8) around selected nodes (this may be due to my confusion or because
of some bugs).

I want to be able to prevent the user moving from
one node to another (under particular circumstances). I was under the
impression that I could use the OnBeforeSelectNode event and change the
variable ACanSelect to false. This is so that they stay on the current
node and cannot move to the newly selected node.

I can see that
the nodes are no longer graphically selected but
AdvTreeView.SelectedNode is now pointing to the newly selected node.

(Using the default entries in TAdvTreeView, this is a much more simplified version of my code):

procedure TForm1.AdvTreeView1BeforeSelectNode(Sender: TObject;
  ANode: TAdvTreeViewVirtualNode; var ACanSelect: Boolean);
var
  node: TAdvTreeViewNode;
begin
  if advTreeView1.SelectedNode <> Nil then
  begin
    node:= advTreeView1.SelectedNode;
    if node.Text[0] = 'SLS' then
    begin
      ACanSelect:= false;
    end;
  end;
end;

So
that when the user is currently on Mercedes SLS and select SLK, I want
that to be prevented and for it to remain on SLS. Whilst the above code
does not graphically highlight SLK (a grey dotted line is put around it)
advTreeView1.SelectedNode.Text[0] equals 'SLK'. I would have expected
SelectedNode to equal nil or 'SLS' node.

Hi, 


Unfortunately when checking the selecting node during a node selection operation is not supported.
To prevent a node from being re-ordered or dragged you should instead use the OnBeforeDropNode or the OnBeforeReorderNode events instead.

I'm essentially using the treeview to show my data structure on the
left, whilst having a more detailed view (using textboxes etc) on the
right of my form. There are times when I am trying to prevent the user
moving away from a selected node until they have met my validation
criteria.

OnBeforeSelectNode sort of works, but I've noticed that
the advTreeView.SelectedNode still changes when ACanSelect is set to
false (even if it isn't highlighted).

Using the example of:

Mercedes:
- SLS
- SLK
- GLA

Where
for this example, once SLS is selected the user cannot select another
node (my real code is more complex and the user can move once the
validation has been met). If the user selects SLK, ACanSelect is set to
false, there are no highlighted nodes, but SLK has a dotted line around
it, AdvTreeView.SelectedNode equals SLK and when I press down on the
keyboard it goes to GLA (which is one down from SLK). It appears that
SLK is selected all but visually.

Hi, 


Alternatively you can use the disabled state of an item. Then it is not selectable:

procedure TForm1.AdvTreeView1IsNodeEnabled(Sender: TObject;
  ANode: TAdvTreeViewVirtualNode; var AEnabled: Boolean);
begin
  AEnabled := not (ANode.Text[0] = 'SLK');
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  AdvTreeView1.NodesAppearance.DisabledFill.Assign(AdvTreeView1.NodesAppearance.Fill);
  AdvTreeView1.NodesAppearance.DisabledStroke.Assign(AdvTreeView1.NodesAppearance.Stroke);
  AdvTreeView1.NodesAppearance.DisabledFontColor := AdvTreeView1.NodesAppearance.FontColor;
end;