Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Delphi 跳过/禁用VirtualTreeView中的节点_Delphi_Vcl_Virtualtreeview - Fatal编程技术网

Delphi 跳过/禁用VirtualTreeView中的节点

Delphi 跳过/禁用VirtualTreeView中的节点,delphi,vcl,virtualtreeview,Delphi,Vcl,Virtualtreeview,我的VirtualStringTree中有5个节点: 节点#4没有标题,当用户按下VK#u或按下VK#u时,应跳过该节点 当用户单击它时,它也不应该被选中 我编写了以下代码(有效)以在使用键盘时跳过所述节点: if Key = VK_DOWN then begin node := VirtualTree.GetNext(VirtualTree.FocusedNode); if not Assigned(node) then Exit; data := VirtualTree.Ge

我的VirtualStringTree中有5个节点:

节点#4没有标题,当用户按下VK#u或按下VK#u时,应跳过该节点

当用户单击它时,它也不应该被选中

我编写了以下代码(有效)以在使用键盘时跳过所述节点:

if Key = VK_DOWN then
begin
  node := VirtualTree.GetNext(VirtualTree.FocusedNode);
  if not Assigned(node) then Exit;

  data := VirtualTree.GetNodeData(node);
  if data^.Caption = '' then
  begin
    VirtualTree.GetNext(node);
    VirtualTree.FocusedNode := node;
    VirtualTree.Selected[node] := true;
  end;
end
else if Key = VK_UP then
begin
  node := VirtualTree.GetPrevious(VirtualTree.FocusedNode);
  if not Assigned(node) then Exit;

  data := VirtualTree.GetNodeData(node);
  if data^.Caption = '' then
  begin
    VirtualTree.GetPrevious(node);
    VirtualTree.FocusedNode := node;
    VirtualTree.Selected[node] := true;
  end;
end;
问题是节点仍然通过单击它来获得焦点

我尝试禁用节点
VirtualTree.IsDisabled[node]:=true-但没有运气


有人知道实现这一点的方法吗?

处理
onfocuschange
事件,并将所选节点的
允许的
参数返回False。

我不知怎的错过了该事件。谢谢:-)不客气!无论如何,最好为您的键盘处理处理处理
OnKeyAction
事件。另外,通过
GetPreviousVisible
GetNextVisible
方法搜索最近的非空节点。别忘了还有更多的键需要处理,至少在你的情况下,
VK_HOME
VK_END
(注意,
onfocuschangg
也会阻止节点被键盘聚焦,因此你需要为所有导航键找到最近的可聚焦节点,否则这些键实际上什么都做不了)。