0

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(); } 

There are 2 classes in a same project. and there are each functions in each class. I wanna call C_B_After_Click_for_nodecheck(object sender, TreeViewEventArgs e) from private void C_B_backupNowButton_Click(object sender, EventArgs e). but, It has a problem about TreeViewEventArgs e. Because C_B_backupNowButton_Click has another type of EventArgs. Is there the way to call the function?

7
  • 3
    Make a separate method (with just the sender as parameter; or not even that, looks like you don't use the sender) and call that from both click event handlers? Commented Aug 13, 2013 at 14:22
  • I tried..but I can't.. 'System.Windows.Forms.TreeViewEventArgs' doesn't have the constructor using 0 ValType. Commented Aug 13, 2013 at 14:27
  • C_B_After_Click_for_nodecheck(sender,e) have you tried that Yona Kim..? Commented Aug 13, 2013 at 14:31
  • It says 'System.Windows.Forms.TreeViewEventArgs' doesn't have the constructor using 0 of ValType' Commented Aug 13, 2013 at 14:31
  • DJ KRAZE, Yes I have. but different type of eventArgs. Commented Aug 13, 2013 at 14:32

1 Answer 1

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(); } 

To add a node you can do this

string childText = "child" ; C_B_treeView.BeginUpdate() C_B_treeView.Nodes.Add(childText); C_B_treeView.EndUpdate(); 

If you want all your nodes to be visible after updating them

C_B_treeView.ExpandAll(); 
Sign up to request clarification or add additional context in comments.

8 Comments

What I wanna do is to check all nodes whether nodes are checked or not. According to ur source, I can apply for special node I designated, right?
@YonaKim for "special node" you mean a class that inherits from TreeNode ?
My treeView name is C_B_treeView. how can I create TreeNode?
And also, C_B_After_Click_for_nodecheck(object sender, TreeViewEventArgs e) isn't needed. anyfunction doesn't call it in ur source.
private void C_B_After_Click_for_nodecheck(object sender, TreeViewEventArgs e) is not Eventhandler. I created it.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.