1.C_backupTPForm.cs
private void C_B_After_Click_for_nodecheck(object sender, TreeViewEventArgs e){
DirectoryInfo rootDir = new DirectoryInfo(e.Node.FullPath);
DirectoryInfo[] directories = rootDir.GetDirectories();
int i = 0;
foreach (DirectoryInfo directory in directories)
{
if (e.Node.Nodes[i++].Checked == true)
{
AL_ftp_filepath.Add(ftp_filePath.ToString());
}
}
}
=============================================== ============================ 2.C_BackupTPForm.cs
private void C_B_backupNowButton_Click(object sender, EventArgs e)
{
*********** C_B_After_Click_for_nodecheck(sender,);************// I wanna call this function here but, I can't
C_R_treeViewShow();
}
同一个项目中有两个班级。并且每个班级都有各自的功能。
我想从C_B_After_Click_for_nodecheck(object sender, TreeViewEventArgs e)
致电private void C_B_backupNowButton_Click(object sender, EventArgs e)
。但是,它有TreeViewEventArgs e
的问题。因为C_B_backupNowButton_Click
有另一种EventArgs
。有没有办法调用该功能?
答案 0 :(得分:2)
public NodeCheck(TreeNode node)
{
DirectoryInfo rootDir = new DirectoryInfo(node.FullPath);
DirectoryInfo[] directories = rootDir.GetDirectories();
int i = 0;
foreach (DirectoryInfo directory in directories)
{
if (e.Node.Nodes[i++].Checked == true)
{
AL_ftp_filepath.Add(ftp_filePath.ToString());
}
}
}
private void C_B_After_Click_for_nodecheck(object sender, TreeViewEventArgs e)
{
NodeCheck(e.Node);
}
private void C_B_backupNowButton_Click(object sender, EventArgs e)
{
TreeNode node ;
node = //Code to get the code that you need/selected one
NodeCheck(node);
C_R_treeViewShow();
}
要添加节点,您可以执行此操作
string childText = "child" ;
C_B_treeView.BeginUpdate()
C_B_treeView.Nodes.Add(childText);
C_B_treeView.EndUpdate();
如果您希望在更新后显示所有节点
C_B_treeView.ExpandAll();