点击一层时判断二层是否存在记录!点击二层时判断三层是否存在记录!
应当怎样作!?

解决方案 »

  1.   

    TTreeView OnClickwith Sender as TTreeView do
    begin
      if Selected.Count > 0 then //存在
      else //不存在
    end;
      

  2.   

    可否解释一下。
    特别是with Sender as TTreeView do中的Sender是作什么用的。
      

  3.   

    不介意我贴帮助文件吧:PIn an event handler, the Sender parameter indicates which component received the event and therefore called the handler. Sometimes it is useful to have several components share an event handler that behaves differently depending on which component calls it. 上面的相当于procedure TForm1.TreeView1Click(Sender: TObject);
    begin
      with TreeView1 do
      begin
        if Selected.Count > 0 then //存在
        else //不存在
      end;
    end;
      

  4.   

    一般应该是 
    if Sender Is TTreeView then
      with TTreeView(Sender) do
      

  5.   

    procedure TForm1.TreeView1Change(Sender: TObject; Node: TTreeNode);
    begin
      if node.HasChildren then
      showmessage('有子节点!');
    end;
      

  6.   

    richardluo(菜鸟.luo)你好:
    呵呵、你说的没错、用TTreeView(Sender)执行效率会快一些:P