ListView控件怎么用呀?
#region 在激活项时发生 /// <summary> /// 当双击ListView的Item时打开文件夹或运行文件 /// </summary> private void listView1_ItemActivate(object sender, System.EventArgs e) { try { if(listView1.FocusedItem.SubItems.Count>1) //is file : 文件 { //judge for file or directory string sPath = treeView1.SelectedNode.FullPath.Remove(0,5); string sFile = listView1.FocusedItem.Text; Process.Start(sPath + "\\" + sFile); //MessageBox.Show(sPath + "\\" + sFile); } else //is directory : 文件夹 { int count = listView1.FocusedItem.Index; //取ListView中当前焦点Item的索引值 if(cutCopy==true) { count = dirCount; cutCopy = false; } //MessageBox.Show(count.ToString()); /* string sPath = treeView1.SelectedNode.FullPath.Remove(0,5); string dirPath = listView1.FocusedItem.Text; TreeNode tempNode = new TreeNode(dirPath); treeView1.SelectedNode = tempNode; */ if(treeView1.SelectedNode.IsExpanded==false) { treeView1.SelectedNode.Expand(); } //MessageBox.Show(treeView1.SelectedNode.Nodes.Count.ToString()); treeView1.SelectedNode = treeView1.SelectedNode.Nodes[count];
} } catch(Exception ex) { MessageBox.Show(ex.ToString()); } } #endregion