2017-10-05 71 views
0

如何移至radtreeview中的上一个节点。我正在使用telerik。 这里是我的负荷女巫显示radtreeview:使用退格移至上一个文件夹

public void LoadDataMyComputer() 
{ 
    try 
    { 
     RadTreeNode rootNode = radTreeView1.Nodes.Add("C:\\work_Bogdan"); 
     rootNode.Tag = "C:\\work_Bogdan"; 
     Stopwatch watch = Stopwatch.StartNew(); 
     LoadFoldersTree(rootNode); 


     watch.Stop(); 
     ParamLoadingTime = (watch.ElapsedMilliseconds/1000.0); 
    } 
    catch (Exception ex) 
    { 
     MessageBox.Show(ex.Message); 
    } 
} 

这里是我的pressKey事件在那里我有写代码移动到文件夹以前:

private void radTreeView1_KeyPress(object sender, KeyPressEventArgs e) 
{ 
    if (e.KeyChar == (char)Keys.Back) 
    { 
     // here have to be the code to move to prev. folder 
     MessageBox.Show("asd"); 
    } 
} 

任何答案是有帮助的。 thx

回答

0

我创建了一个节点列表。

然后当我按退格键,它加载我与以前的节点形式(m_History [m_History.Count - 1]是一个节点)

和代码如下所示:

private void radTreeView1_KeyPress(object sender, KeyPressEventArgs e) 
    { 
     //if backspace is pressed go to previous node 
     if (e.KeyChar == (char)Keys.Back) 
     { 
      if (m_History.Count == 0) 
       return; 

      RadTreeNode nNode = m_History[m_History.Count - 1]; 
      //Load with the m_History[m_History.Count - 1] node from the list(m_History) 
      LoadTree(nNode); 

      //remove the last node 
      m_History.Remove(nNode); 
     } 
    } 
相关问题