2017-10-05 69 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); 
     } 
    } 
相關問題